本文整理汇总了Java中gnu.trove.TIntDoubleHashMap类的典型用法代码示例。如果您正苦于以下问题:Java TIntDoubleHashMap类的具体用法?Java TIntDoubleHashMap怎么用?Java TIntDoubleHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TIntDoubleHashMap类属于gnu.trove包,在下文中一共展示了TIntDoubleHashMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compute
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public double compute(TIntDoubleHashMap doc1, TIntDoubleHashMap doc2, IIntIterator features) {
double numerator = 0;
double denominator1 = 0;
double denominator2 = 0;
features.begin();
while (features.hasNext()) {
int featID = features.next();
double doc1s = doc1.get(featID);
double doc2s = doc2.get(featID);
numerator += (doc1s * doc2s);
denominator1 += (doc1s * doc1s);
denominator2 += (doc2s * doc2s);
}
double denominator = Math.sqrt(denominator1) * Math.sqrt(denominator2);
double similarity = numerator / denominator;
if (similarity > 1)
similarity = 1;
return similarity;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:27,代码来源:CosineSimilarityFunction.java
示例2: compute
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public double compute(int doc1, int doc2, IIndex index) {
TIntDoubleHashMap ar1 = new TIntDoubleHashMap(index.getFeatureDB()
.getFeaturesCount());
TIntDoubleHashMap ar2 = new TIntDoubleHashMap(index.getFeatureDB()
.getFeaturesCount());
IIntIterator features = index.getFeatureDB().getFeatures();
while (features.hasNext()) {
int featID = features.next();
ar1.put(featID,
index.getWeightingDB().getDocumentFeatureWeight(doc1,
featID));
ar2.put(featID,
index.getWeightingDB().getDocumentFeatureWeight(doc2,
featID));
}
features.begin();
return compute(ar1, ar2, features);
}
开发者ID:jatecs,项目名称:jatecs,代码行数:23,代码来源:BaseSimilarityFunction.java
示例3: get
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public TIntArrayList get(TIntDoubleHashMap table) {
final ArrayList<ComparablePair> list = new ArrayList<ComparablePair>(
table.size());
class Procedure implements TIntDoubleProcedure {
@Override
public boolean execute(int a, double b) {
list.add(new ComparablePair(a, b));
return true;
}
}
table.forEachEntry(new Procedure());
Collections.sort(list);
TIntArrayList result = new TIntArrayList(list.size());
for (int i = 0; i < list.size(); i++) {
result.add(list.get(i).getFirst());
}
return result;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:19,代码来源:Ranker.java
示例4: Incremental
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public Incremental(int trainSize, ClassificationScoreDB classification, TIntHashSet categoriesFilter,
EstimationType estimation, ContingencyTableSet evaluation, IGain gain, IGain firstRankGain, double[] probabilitySlope, double[] prevalencies) {
super(trainSize, classification, categoriesFilter, estimation, evaluation, firstRankGain, probabilitySlope, prevalencies);
macroRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75);
microRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75);
macroAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75);
microAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75);
probabilities = new double[testSize][numOfCategories];
for (int docId = 0; docId < testSize; docId++) {
Set<Entry<Short, ClassifierRangeWithScore>> entries = classification.getDocumentScoresAsSet(docId);
Iterator<Entry<Short, ClassifierRangeWithScore>> iterator = entries.iterator();
while (iterator.hasNext()) {
Entry<Short, ClassifierRangeWithScore> next = iterator.next();
ClassifierRangeWithScore value = next.getValue();
if (categoriesFilter.contains(next.getKey())) {
probabilities[docId][catMap.get(next.getKey())] = probability(Math.abs(value.score - value.border), next.getKey());
}
}
}
}
开发者ID:jatecs,项目名称:jatecs,代码行数:21,代码来源:Incremental.java
示例5: getTable
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public TIntDoubleHashMap getTable() {
TIntDoubleHashMap rank = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75);
for (int docId = 0; docId < testSize; docId++) {
Set<Entry<Short, ClassifierRangeWithScore>> entries = classification.getDocumentScoresAsSet(docId);
Iterator<Entry<Short, ClassifierRangeWithScore>> iterator = entries.iterator();
double sum = 0.0;
while (iterator.hasNext()) {
Entry<Short, ClassifierRangeWithScore> next = iterator.next();
if (categoriesFilter.contains(next.getKey()) && docCategoriesFilter[docId].contains(next.getKey())) {
ClassifierRangeWithScore value = next.getValue();
sum += probability(Math.abs(value.score - value.border), next.getKey());
//System.out.println(docId + " " + next.getKey() + " " + probability(Math.abs(value.score - value.border), next.getKey()));
//System.out.println(next.getKey() + " " + slopes[next.getKey()] + " " + value.score);
}
}
rank.put(docId, sum);
}
return rank;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:20,代码来源:ConfidenceBased.java
示例6: addEdge
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public void addEdge(int i, int j, double weight) {
ExceptionUtility.verifyIndex(this.numVertices, i);
ExceptionUtility.verifyIndex(this.numVertices, j);
int x = (i < j ? i : j);
int y = (i < j ? j : i);
if (!this.adjacencySets.containsKey(y)) {
this.adjacencySets.put(y, new TIntDoubleHashMap());
}
this.adjacencySets.get(y).put(x, weight);
if (!this.degrees.containsKey(x)) {
this.degrees.put(x, 0);
}
if (!this.degrees.containsKey(y)) {
this.degrees.put(y, 0);
}
this.degrees.put(x, this.degrees.get(x) + 1);
this.degrees.put(y, this.degrees.get(y) + 1);
}
开发者ID:appliedtopology,项目名称:javaplex,代码行数:20,代码来源:UndirectedWeightedListGraph.java
示例7: TroveWeightingDB
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public TroveWeightingDB(IContentDB contentDB) {
super();
_contentDB = contentDB;
int size = contentDB.getDocumentDB().getDocumentsCount();
_documentsWeights = new Vector<TIntDoubleHashMap>(size);
for (int i = 0; i < size; ++i) {
_documentsWeights.add(new TIntDoubleHashMap());
}
_name = "generic";
}
开发者ID:jatecs,项目名称:jatecs,代码行数:12,代码来源:TroveWeightingDB.java
示例8: getDocumentFeatureWeight
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public double getDocumentFeatureWeight(int document, int feature) {
if (_contentDB.hasDocumentFeature(document, feature)) {
if (document < _documentsWeights.size()) {
TIntDoubleHashMap weights = _documentsWeights.get(document);
if (weights.containsKey(feature))
return weights.get(feature);
else
return 1.0;
} else
return 1.0;
} else
return 0.0;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:14,代码来源:TroveWeightingDB.java
示例9: cloneDB
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public IWeightingDB cloneDB(IContentDB contentDB) {
TroveWeightingDB weightingDB = new TroveWeightingDB(contentDB);
weightingDB._name = new String(_name);
weightingDB._documentsWeights = new Vector<TIntDoubleHashMap>(
_documentsWeights.size());
for (int i = 0; i < _documentsWeights.size(); ++i)
weightingDB._documentsWeights
.add((TIntDoubleHashMap) _documentsWeights.get(i).clone());
return weightingDB;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:13,代码来源:TroveWeightingDB.java
示例10: setDocumentFeatureWeight
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public void setDocumentFeatureWeight(int document, int feature,
double weight) {
if (_weightingDB.getContentDB().hasDocumentFeature(document, feature)) {
while (document >= _weightingDB._documentsWeights.size())
_weightingDB._documentsWeights.add(new TIntDoubleHashMap());
_weightingDB._documentsWeights.get(document).put(feature, weight);
}
}
开发者ID:jatecs,项目名称:jatecs,代码行数:9,代码来源:TroveWeightingDBBuilder.java
示例11: computeDocumentCentroid
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public static TIntDoubleHashMap computeDocumentCentroid(IIntIterator docs,
IIndex index) {
TIntDoubleHashMap centroid = new TIntDoubleHashMap(index.getFeatureDB()
.getFeaturesCount());
int numDoc = 0;
docs.begin();
while (docs.hasNext()) {
int docID = docs.next();
IIntIterator feats = index.getContentDB()
.getDocumentFeatures(docID);
while (feats.hasNext()) {
int featID = feats.next();
centroid.put(
featID,
centroid.get(featID)
+ index.getWeightingDB()
.getDocumentFeatureWeight(docID, featID));
}
numDoc++;
}
int keys[] = centroid.keys();
for (int i = 0; i < keys.length; i++) {
centroid.put(keys[i], centroid.get(keys[i]) / (double) numDoc);
}
return centroid;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:32,代码来源:Clustering.java
示例12: compute
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public double compute(TIntDoubleHashMap doc1, TIntDoubleHashMap doc2, IIntIterator features) {
double l = 0;
features.begin();
while (features.hasNext()) {
int featID = features.next();
l += Math.pow(doc1.get(featID) - doc2.get(featID), 2);
}
l = Math.sqrt(l);
return l;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:15,代码来源:EuclideanDistance.java
示例13: compute
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public double compute(TIntDoubleHashMap doc1, TIntDoubleHashMap doc2, IIntIterator features) {
double dist = 0;
features.begin();
while(features.hasNext()){
int featID = features.next();
dist += Math.pow(doc1.get(featID)-doc2.get(featID), 2);
}
return dist;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:13,代码来源:EuclideanSquareDistance.java
示例14: getMax
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
static public int getMax(TIntDoubleHashMap table) {
int maxKey = -Integer.MIN_VALUE;
double maxValue = Double.NEGATIVE_INFINITY;
TIntDoubleIterator it = table.iterator();
while (it.hasNext()) {
it.advance();
if (it.value() > maxValue) {
maxValue = it.value();
maxKey = it.key();
}
}
return maxKey;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:14,代码来源:Ranker.java
示例15: getTable
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public TIntDoubleHashMap getTable(double[][] utilities) {
TIntDoubleHashMap rank = new TIntDoubleHashMap(
(int) (testSize + testSize * 0.25), (float) 0.75);
for (int docId = 0; docId < testSize; docId++) {
double sum = 0.0;
for (TIntIterator it = categoriesFilter.iterator(); it.hasNext(); ) {
int catId = it.next();
if (docCategoriesFilter[docId].contains(catId)) {
sum += utilities[docId][catMap.get(catId)];
}
}
rank.put(docId, sum);
}
return rank;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:16,代码来源:UtilityBased.java
示例16: filterByTopProbabilities
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
private TIntHashSet filterByTopProbabilities(int docId, int topK) {
TIntDoubleHashMap topProbRank = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75);
Set<Entry<Short, ClassifierRangeWithScore>> entries = classification.getDocumentScoresAsSet(docId);
Iterator<Entry<Short, ClassifierRangeWithScore>> iterator = entries.iterator();
while (iterator.hasNext()) {
Entry<Short, ClassifierRangeWithScore> next = iterator.next();
if (categoriesFilter.contains(next.getKey())) {
ClassifierRangeWithScore value = next.getValue();
topProbRank.put(next.getKey(), probability(Math.abs(value.score - value.border), next.getKey()));
}
}
Ranker r = new Ranker();
return new TIntHashSet(r.get(topProbRank).toNativeArray(0, topK));
}
开发者ID:jatecs,项目名称:jatecs,代码行数:15,代码来源:ConfidenceBased.java
示例17: getTable
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public TIntDoubleHashMap getTable() {
TIntDoubleHashMap rank = new TIntDoubleHashMap(testSize);
for (int i = 0; i < testSize; i++) {
rank.put(i, Math.random());
}
return rank;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:8,代码来源:Random.java
示例18: getTable
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
@Override
public TIntDoubleHashMap getTable() {
TIntDoubleHashMap rank = super.getTable();
for (int docId = 0; docId < testSize; docId++) {
if (rank.get(docId) != 0.0) {
rank.adjustValue(docId, Math.random());
}
}
return rank;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:11,代码来源:ConfidenceBasedOracle.java
示例19: SparseVector
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
public SparseVector(SparseVector other) {
_dim_value = new TIntDoubleHashMap(other.size());
int[] dims=other._dim_value.keys();
for(int dim:dims)
_dim_value.put(dim, other._dim_value.get(dim));
_k = other._k;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:8,代码来源:SparseVector.java
示例20: getDocumentAsMap
import gnu.trove.TIntDoubleHashMap; //导入依赖的package包/类
protected TIntDoubleHashMap getDocumentAsMap(int docID, IIndex index) {
TIntDoubleHashMap d2 = new TIntDoubleHashMap(index.getFeatureDB()
.getFeaturesCount());
IIntIterator features = index.getFeatureDB().getFeatures();
while (features.hasNext()) {
int featID = features.next();
d2.put(featID,
index.getWeightingDB().getDocumentFeatureWeight(docID,
featID));
}
return d2;
}
开发者ID:jatecs,项目名称:jatecs,代码行数:14,代码来源:BestAutomaticNegativesChooser.java
注:本文中的gnu.trove.TIntDoubleHashMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论