当前位置: 首页>>代码示例>>Java>>正文


Java Int2DoubleMap.put方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2DoubleMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java Int2DoubleMap.put方法的具体用法?Java Int2DoubleMap.put怎么用?Java Int2DoubleMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.ints.Int2DoubleMap的用法示例。


在下文中一共展示了Int2DoubleMap.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: featurize

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
public LearningInstance featurize(JsonNode entity, boolean update) {
    Map<String, List<Feature>> feaMap = new HashMap<>();
    for (FeatureExtractor extractor : featureExtractors) {
        feaMap.putAll(extractor.extract(entity, update,
                indexSpace));
    }
    Int2DoubleMap feas = new Int2DoubleOpenHashMap();
    for (String fea : features) {
        if (feaMap.containsKey(fea)) {
            for (Feature feature : feaMap.get(fea)) {
                feas.put(feature.getIndex(), feature.getValue());
            }
        }
    }
    double label = StandardLearningInstance.defaultLabel;
    double weight = StandardLearningInstance.defaultWeight;
    if (entity.has(labelName)) {
        label = entity.get(labelName).asDouble();
    } else if (feaMap.containsKey(labelName)) {
        label = feaMap.get(labelName).get(0).getValue();
    }
    if (entity.has(weightName)) {
        weight = entity.get(weightName).asDouble();
    } else if (feaMap.containsKey(weightName)) {
        weight = feaMap.get(weightName).get(0).getValue();
    }
    String group = null;
    if (groupKeys != null && groupKeys.size() > 0) {
        group = FeatureExtractorUtilities.composeConcatenatedKey(entity, groupKeys);
    }
    return new StandardLearningInstance(feas, label, weight, group);
}
 
开发者ID:grouplens,项目名称:samantha,代码行数:33,代码来源:StandardFeaturizer.java

示例2: scores

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
@Override
public Int2DoubleMap scores(int docI) {
	IntSet successors = successors(docI);
	Int2DoubleMap results = new Int2DoubleOpenHashMap(successors.size());
	IntSet catI = page2cat.get(docI);
	for (int docJ : successors) {
		IntSet catJ = page2cat.get(docJ);
		results.put(docJ, -expectedness(catI, catJ));
	}
	return results;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:12,代码来源:LlamaFurScorer.java

示例3: scores

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
@Override
public Int2DoubleMap scores(int docI) {
	Int2DoubleMap originalScores = scorer.scores(docI);
	ObjectIterator<Entry> iterator = originalScores.int2DoubleEntrySet().iterator();
	Int2DoubleMap newScores = new Int2DoubleOpenHashMap(originalScores.size());
	for (Entry entry = iterator.next(); iterator.hasNext(); entry = iterator.next()) {
		newScores.put(entry.getIntKey(), 
				(entry.getDoubleValue() - mean) / stddev
				);
	}
	return newScores;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:13,代码来源:StudentizedCombinationScorer.java

示例4: testGlobalModel

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
/**
 * Tests the global probability method (BinomialModel::p).
 */
@Test
public void testGlobalModel() {
    Int2DoubleMap expectedGlobalP = new Int2DoubleOpenHashMap();
    expectedGlobalP.put(1, 0.8);
    expectedGlobalP.put(2, 0.2);
    
    BinomialModel<Integer, Integer, Integer> bm = new BinomialModel<>(false, Stream.empty(), preferences, featureData, 0.0);
    
    assertEquals(expectedGlobalP.keySet(), bm.getFeatures());
    expectedGlobalP.forEach((f, p) -> assertEquals(p, bm.p(f), 0.0001));
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:15,代码来源:BinomialModelTest.java

示例5: testLocalModelAlpha00

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
/**
 * Tests the local (user) probability method with alpha = 0.0.
 */
@Test
public void testLocalModelAlpha00() {
    Int2DoubleMap expectedLocalP = new Int2DoubleOpenHashMap();
    expectedLocalP.put(1, 0.8);
    expectedLocalP.put(2, 0.2);
    
    checkLocalModel(0.0, expectedLocalP);
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:12,代码来源:BinomialModelTest.java

示例6: testLocalModelAlpha05

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
/**
 * Tests the local (user) probability method with alpha = 0.5.
 */
@Test
public void testLocalModelAlpha05() {
    Int2DoubleMap expectedLocalP = new Int2DoubleOpenHashMap();
    expectedLocalP.put(1, 0.9);
    expectedLocalP.put(2, 0.1);
    
    checkLocalModel(0.5, expectedLocalP);
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:12,代码来源:BinomialModelTest.java

示例7: testLocalModelAlpha10

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
/**
 * Tests the local (user) probability method with alpha = 1.0.
 */
@Test
public void testLocalModelAlpha10() {
    Int2DoubleMap expectedLocalP = new Int2DoubleOpenHashMap();
    expectedLocalP.put(1, 1.0);
    
    checkLocalModel(1.0, expectedLocalP);
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:11,代码来源:BinomialModelTest.java

示例8: predict

import it.unimi.dsi.fastutil.ints.Int2DoubleMap; //导入方法依赖的package包/类
/**
 * Does not alter the model's state, as requested by interface.
 */
@Override
public int predict(SparseBinaryVector featureVector, String options, Int2DoubleMap decisionScores) {
    if (model == null) throw new RuntimeException("No model loaded or trained.");
    double[] decisionValues = new double[model.getNrClass()];
    int bestClass = (int)Linear.predictValues(model, vector2FeatureArray(featureVector), decisionValues);
    // If user wants the decision scores for each class
    if (decisionScores != null) {
        // Produce a mapping from each class ID to its decision score
        int[] labelOrder = model.getLabels();
        for (int i = 0; i < decisionValues.length; i++){
            decisionScores.put(labelOrder[i], decisionValues[i]);
        }
    } return bestClass;
}
 
开发者ID:andehr,项目名称:tag-dependency-parser,代码行数:18,代码来源:ClassifierLinearSVM.java


注:本文中的it.unimi.dsi.fastutil.ints.Int2DoubleMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。