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


Java Object2DoubleOpenHashMap类代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap的典型用法代码示例。如果您正苦于以下问题:Java Object2DoubleOpenHashMap类的具体用法?Java Object2DoubleOpenHashMap怎么用?Java Object2DoubleOpenHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Object2DoubleOpenHashMap类属于it.unimi.dsi.fastutil.objects包,在下文中一共展示了Object2DoubleOpenHashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVector

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public Object2DoubleMap<String> getVector(Language lang, String value) {
    Object2DoubleMap<String> uriWeightMap = new Object2DoubleOpenHashMap<>();
    
    try {
        Search luceneSearch = search();
        final String field = getContentFieldName(lang);
        
        TopScoreDocCollector docsCollector = luceneSearch.search(value, field);
        
        ScoreDoc[] scoreDocs = docsCollector.topDocs().scoreDocs;
        
        double score = 0.0;
        for(int i=0;i<scoreDocs.length;++i) {
            int docID = scoreDocs[i].doc;
            score = scoreDocs[i].score;
            Document document = luceneSearch.getDocumentWithDocID(docID);
            String uri = document.get(fieldNameURI);
            uriWeightMap.put(uri, score);
        }
        return uriWeightMap;
    } catch(IOException x) {
        throw new RuntimeException(x);
    }
}
 
开发者ID:jmccrae,项目名称:naisc,代码行数:25,代码来源:Corpus.java

示例2: testExtractFeatures

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
/**
 * Test of extractFeatures method, of class CLESAFeatureExtractor.
 */
@Test
public void testExtractFeatures() {
    System.out.println("extractFeatures");
    LangStringPair facet = new LangStringPair(Language.ENGLISH, Language.GERMAN, "test", "Test");
    String id1 = "id1";
    String id2 = "id2";
    Corpus corpus = mock(Corpus.class);
    Object2DoubleMap<String> v1 = new Object2DoubleOpenHashMap<>();
    v1.put("a", 0.2);
    v1.put("b", 0.3);
    Object2DoubleMap<String> v2 = new Object2DoubleOpenHashMap<>();
    v2.put("a", 0.5);
    when(corpus.getVector(Language.ENGLISH, "test")).thenReturn(v1);
    when(corpus.getVector(Language.GERMAN, "Test")).thenReturn(v2);
    CLESAFeatureExtractor instance = new CLESAFeatureExtractor(corpus);
    double[] expResult = new double[] { .2*.5 / Math.sqrt((.2*.2 +.3*0.3)*(0.5*0.5)) };
    double[] result = instance.extractFeatures(facet, id1, id2);
    assertArrayEquals(expResult, result, 0.0);
}
 
开发者ID:jmccrae,项目名称:naisc,代码行数:23,代码来源:CLESAFeatureExtractorTest.java

示例3: main

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        Table table = Table.read().csv(CsvReadOptions
            .builder("../data/movielens.data")
            .separator('\t'));

        double supportThreshold = .25;
        double confidenceThreshold = .5;
        double interestThreshold = .5;

        AssociationRuleMining model = new AssociationRuleMining(table.shortColumn("user"), table.shortColumn("movie")
                , supportThreshold);

        FrequentItemset frequentItemsetModel = new FrequentItemset(table.shortColumn("user"), table.shortColumn
                ("movie"), supportThreshold);
        Object2DoubleOpenHashMap<IntRBTreeSet> confidenceMap = frequentItemsetModel.confidenceMap();

        Table interestingRuleTable = model.interest(confidenceThreshold, interestThreshold, confidenceMap);

        interestingRuleTable = interestingRuleTable.sortDescendingOn("Interest", "Antecedent");
        out(interestingRuleTable);
    }
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:23,代码来源:AssociationRuleMiningExample.java

示例4: BinomialNonRedundancyUserReranker

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param recommendation input recommendation to be re-ranked
 * @param maxLength number of items to be greedily selected
 */
public BinomialNonRedundancyUserReranker(Recommendation<U, I> recommendation, int maxLength) {
    super(recommendation, maxLength);

    ubm = binomialModel.getModel(recommendation.getUser());

    featureCount = new Object2IntOpenHashMap<>();
    featureCount.defaultReturnValue(0);

    patienceNow = new Object2DoubleOpenHashMap<>();
    patienceLater = new Object2DoubleOpenHashMap<>();
    ubm.getFeatures().forEach(f -> {
        patienceNow.put(f, ubm.patience(0, f, cutoff));
        patienceLater.put(f, ubm.patience(1, f, cutoff));
    });
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:22,代码来源:BinomialNonRedundancyReranker.java

示例5: run

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
/**
 * Executes the PageRank algorithm by setting the PAGERANK property on all nodes.
 */
public void run() {
	try (Neo4jTransactionManager transactionManager = new Neo4jTransactionManager(graphDatabase)) {
		// Initialize the PageRank value of each node to 1/numberOfVertices
		initializeValues();
		newPrValues = new Object2DoubleOpenHashMap<>(prValues.size());

		for (int iteration = 0; iteration < maxIterations; iteration++) {
			newDanglingSum = 0.0;

			for (Node node : prValues.keySet()) {
				computeNewValue(node);
			}

			swapAfterIteration();
		}

		writeValues(transactionManager);
	}
}
 
开发者ID:atlarge-research,项目名称:graphalytics-platforms-neo4j,代码行数:23,代码来源:PageRankComputation.java

示例6: getGenericRelatedness

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
private double getGenericRelatedness(int wid1, int wid2, Object2DoubleOpenHashMap<Pair<Integer,Integer>> cache, String url){
	if (wid2 < wid1) {
		int tmp = wid2;
		wid2 = wid1;
		wid2 = tmp;
	}
	Pair <Integer,Integer> p = new Pair<Integer,Integer>(wid1,wid2);
	if (!cache.containsKey(p))
		cache.put(p, queryJsonRel(wid1, wid2, url));
		
	return cache.getDouble(p);
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:13,代码来源:WATRelatednessComputer.java

示例7: getRankerConfig

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public static RankerConfig getRankerConfig(Configuration rankerConfig,
                                           Injector injector) {
    int pageSize = 24;
    if (rankerConfig.asMap().containsKey(ConfigKey.RANKER_PAGE_SIZE.get())) {
        rankerConfig.getInt(ConfigKey.RANKER_PAGE_SIZE.get());
    }
    Object2DoubleMap<String> defaults = new Object2DoubleOpenHashMap<>();
    Configuration defaultConfig = rankerConfig.getConfig("blendingDefaults");
    for (String key : defaultConfig.keys()) {
        defaults.put(key, defaultConfig.getDouble(key));
    }
    List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(rankerConfig);
    return new PercentileBlendingRankerConfig(pageSize, defaults, expanders, injector, rankerConfig);
}
 
开发者ID:grouplens,项目名称:samantha,代码行数:15,代码来源:PercentileBlendingRankerConfig.java

示例8: getRankerConfig

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public static RankerConfig getRankerConfig(Configuration rankerConfig,
                                           Injector injector) {
    int pageSize = 24;
    if (rankerConfig.asMap().containsKey(ConfigKey.RANKER_PAGE_SIZE.get())) {
        rankerConfig.getInt(ConfigKey.RANKER_PAGE_SIZE.get());
    }
    Object2DoubleMap<String> defaults = new Object2DoubleOpenHashMap<>();
    Configuration defaultConfig = rankerConfig.getConfig("blendingDefaults");
    for (String key : defaultConfig.keys()) {
        defaults.put(key, defaultConfig.getDouble(key));
    }
    List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(rankerConfig);
    return new FieldBlendingRankerConfig(pageSize, defaults, expanders, injector, rankerConfig);
}
 
开发者ID:grouplens,项目名称:samantha,代码行数:15,代码来源:FieldBlendingRankerConfig.java

示例9: getPredictorConfig

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public static PredictorConfig getPredictorConfig(Configuration predictorConfig,
                                                 Injector injector) {
    Object2DoubleMap<String> defaults = new Object2DoubleOpenHashMap<>();
    Configuration defaultConfig = predictorConfig.getConfig("blendingDefaults");
    for (String key : defaultConfig.keys()) {
        defaults.put(key, defaultConfig.getDouble(key));
    }
    List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(predictorConfig);
    return new FieldBlendingPredictorConfig(predictorConfig,
            predictorConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get()),
            injector, expanders, defaults, predictorConfig.getString("daoConfigKey"));
}
 
开发者ID:grouplens,项目名称:samantha,代码行数:13,代码来源:FieldBlendingPredictorConfig.java

示例10: getTriggeredFeatures

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public List<ObjectNode> getTriggeredFeatures(List<ObjectNode> bases) {
    Object2DoubleMap<String> item2score = new Object2DoubleOpenHashMap<>();
    int numInter = 0;
    for (ObjectNode inter : bases) {
        double weight = 1.0;
        if (inter.has(weightAttr)) {
            weight = inter.get(weightAttr).asDouble();
        }
        String key = FeatureExtractorUtilities.composeConcatenatedKey(inter, feaAttrs);
        if (weight >= 0.5 && featureKnnModel != null) {
            getNeighbors(item2score, featureKnnModel, key, weight);
        }
        if (weight < 0.5 && featureKdnModel != null) {
            getNeighbors(item2score, featureKdnModel, key, weight);
        }
        numInter++;
        if (numInter >= maxInter) {
            break;
        }
    }
    List<ObjectNode> results = new ArrayList<>();
    for (Map.Entry<String, Double> entry : item2score.entrySet()) {
        ObjectNode entity = Json.newObject();
        Map<String, String> attrVals = FeatureExtractorUtilities.decomposeKey(entry.getKey());
        for (Map.Entry<String, String> ent : attrVals.entrySet()) {
            entity.put(ent.getKey(), ent.getValue());
        }
        entity.put(scoreAttr, entry.getValue());
        results.add(entity);
    }
    results.sort(SortingUtilities.jsonFieldReverseComparator(scoreAttr));
    return results;
}
 
开发者ID:grouplens,项目名称:samantha,代码行数:34,代码来源:KnnModelFeatureTrigger.java

示例11: getFactorFeatures

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public Object2DoubleMap<String> getFactorFeatures(int minSupport) {
    int numFeas = indexSpace.getKeyMapSize(SVDFeatureKey.FACTORS.get());
    Object2DoubleMap<String> fea2sup = new Object2DoubleOpenHashMap<>();
    for (int i=0; i<numFeas; i++) {
        String feature = (String)indexSpace.getKeyForIndex(SVDFeatureKey.FACTORS.get(), i);
        if (indexSpace.containsKey(SVDFeatureKey.BIASES.get(), feature)) {
            int idx = indexSpace.getIndexForKey(SVDFeatureKey.BIASES.get(), feature);
            double support = variableSpace.getScalarVarByNameIndex(SVDFeatureKey.SUPPORT.get(), idx);
            if (support >= minSupport) {
                fea2sup.put(feature, support);
            }
        }
    }
    return fea2sup;
}
 
开发者ID:grouplens,项目名称:samantha,代码行数:16,代码来源:SVDFeature.java

示例12: interestingRules

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public List<AssociationRule> interestingRules(double confidenceThreshold,
                                              double interestThreshold,
                                              Object2DoubleOpenHashMap<IntRBTreeSet> confidenceMap) {
    List<AssociationRule> rules = model.learn(confidenceThreshold);
    for (AssociationRule rule : rules) {
        double interest = rule.confidence - confidenceMap.getDouble(rule.consequent);
        if (Math.abs(interest) < interestThreshold) {
            rules.remove(rule);
        }
    }
    return rules;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:13,代码来源:AssociationRuleMining.java

示例13: UserPM

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
public UserPM(Recommendation<U, I> recommendation, int maxLength) {
    super(recommendation, maxLength);

    this.ubm = binomialModel.getModel(recommendation.getUser());
    this.featureCount = new Object2DoubleOpenHashMap<>();
    featureCount.defaultReturnValue(0.0);
    this.probNorm = new Object2DoubleOpenHashMap<>();
    recommendation.getItems()
            .forEach(i -> featureData.getItemFeatures(i.v1).sequential()
                    .forEach(fv -> probNorm.addTo(fv.v1, i.v2)));
    this.lcf = getLcf();
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:13,代码来源:PM.java

示例14: AbstractSalesDiversityMetric

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param cutoff maximum length of the recommendation lists that is evaluated
 * @param disc ranking discount model
 * @param rel relevance model
 */
public AbstractSalesDiversityMetric(int cutoff, RankingDiscountModel disc, RelevanceModel<U, I> rel) {
    this.cutoff = cutoff;
    this.disc = disc;
    this.rel = rel;

    this.itemCount = new Object2DoubleOpenHashMap<>();
    this.itemCount.defaultReturnValue(0.0);
    this.itemWeight = new Object2DoubleOpenHashMap<>();
    this.itemWeight.defaultReturnValue(0.0);
    this.freeNorm = 0;
    this.numUsers = 0;
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:20,代码来源:AbstractSalesDiversityMetric.java

示例15: evaluate

import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; //导入依赖的package包/类
/**
 * Returns a score for the recommendation list.
 *
 * @param recommendation recommendation list
 * @return score of the metric to the recommendation
 */
@Override
public double evaluate(Recommendation<U, I> recommendation) {
    RelevanceModel.UserRelevanceModel<U, I> userRelModel = relModel.getModel(recommendation.getUser());
    UserIntentModel<U, I, F> uim = intentModel.getModel(recommendation.getUser());

    DoubleAdder erria = new DoubleAdder();

    Object2DoubleMap<F> pNoPrevRel = new Object2DoubleOpenHashMap<>();
    pNoPrevRel.defaultReturnValue(0.0);
    uim.getIntents().forEach(f -> pNoPrevRel.put(f, 1.0));

    AtomicInteger rank = new AtomicInteger();
    recommendation.getItems().stream().limit(cutoff).forEach(iv -> {
        if (userRelModel.isRelevant(iv.v1)) {
            double gain = userRelModel.gain(iv.v1);
            uim.getItemIntents(iv.v1).forEach(f -> {
                double red = pNoPrevRel.getDouble(f);
                erria.add(uim.pf_u(f) * gain * red / (1.0 + rank.intValue()));
                pNoPrevRel.put(f, red * (1 - gain));
            });
        }
        rank.incrementAndGet();
    });

    return erria.doubleValue();
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:33,代码来源:ERRIA.java


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