com.davidbracewell.apollo.ml.clustering.topic.TopicCluster Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo Show documentation
Show all versions of apollo Show documentation
A machine learning library for Java.
The newest version!
package com.davidbracewell.apollo.ml.clustering.topic;
import com.davidbracewell.apollo.linear.NDArray;
import com.davidbracewell.apollo.ml.clustering.Cluster;
import java.util.HashMap;
import java.util.Map;
/**
* Specialized cluster to allow fast lookup of vector scores.
*
* @author David B. Bracewell
*/
class TopicCluster extends Cluster {
private static final long serialVersionUID = 1L;
private final Map scores = new HashMap<>();
/**
* Adds a point (vector) to the cluster
*
* @param vector the vector to add
* @param score the score of the vector
*/
public void addPoint(NDArray vector, double score) {
super.addPoint(vector);
scores.put(vector, score);
}
@Override
public void clear() {
super.clear();
scores.clear();
}
@Override
public double getScore(NDArray point) {
return scores.getOrDefault(point, 0.0);
}
}// END OF TopicCluster
© 2015 - 2025 Weber Informatics LLC | Privacy Policy