public class Assignments extends Object implements Iterable<Assignment>
Clustering
implementations. This class
records the number of clusters created, the assignments for each value, and
helper methods for constructing the centroids of a cluster.Constructor and Description |
---|
Assignments(int numClusters,
Assignment[] initialAssignments)
Creates a new
Assignments instance that takes ownership of the
initialAssignments array. |
Assignments(int numClusters,
Assignment[] initialAssignments,
Matrix matrix)
Creates a new
Assignments instance that takes ownership of the
initialAssignments array. |
Assignments(int numClusters,
int numAssignments)
|
Assignments(int numClusters,
int numAssignments,
Matrix matrix)
|
Modifier and Type | Method and Description |
---|---|
Assignment[] |
assignments()
Returns the array of
Assignment objects. |
List<Set<Integer>> |
clusters()
Returns the data point indices assigned to each cluster.
|
int[] |
clusterSizes() |
Assignment |
get(int i)
Returns the
Assignment object at index i . |
DoubleVector[] |
getCentroids()
Returns an array of dense centroid vectors of each discovered cluster
which are scaled according the the number of data points asisgned to that
cluster.
|
SparseDoubleVector[] |
getSparseCentroids()
Returns an array of sparse centroid vectors of each discovered cluster
which are scaled according the the number of data points asisgned to that
cluster.
|
Iterator<Assignment> |
iterator()
Returns an iterator over the
Assignment objects stored. |
int |
numClusters()
Returns the number of clusters.
|
void |
set(int i,
Assignment assignment)
|
int |
size()
Returns the number of
Assignment objects stored. |
public Assignments(int numClusters, int numAssignments)
Assignments
instance that can hold up to numAssignments
Assignment
s. This assumes that the data matrix
will not be accessible. Calls to getCentroids()
will fail when
using this constructor.public Assignments(int numClusters, int numAssignments, Matrix matrix)
public Assignments(int numClusters, Assignment[] initialAssignments)
Assignments
instance that takes ownership of the
initialAssignments
array. This assumes that the data matrix will
not be accessible. Calls to getCentroids()
will fail when using
this constructor.public Assignments(int numClusters, Assignment[] initialAssignments, Matrix matrix)
Assignments
instance that takes ownership of the
initialAssignments
array.public void set(int i, Assignment assignment)
public int size()
Assignment
objects stored.public Iterator<Assignment> iterator()
Assignment
objects stored.iterator
in interface Iterable<Assignment>
public Assignment get(int i)
Assignment
object at index i
.public int numClusters()
public Assignment[] assignments()
Assignment
objects.public List<Set<Integer>> clusters()
public DoubleVector[] getCentroids()
Matrix
holding the data points contains rows of feature vectors.public SparseDoubleVector[] getSparseCentroids()
Matrix
is sparse. Note
that this method assumes that the original Matrix
holding the
data points contains rows of feature vectors.public int[] clusterSizes()
Copyright © 2012. All Rights Reserved.