
com.brettonw.math.ClusterAlgorithm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clustering Show documentation
Show all versions of clustering Show documentation
Clustering is a Java library for identifying similar data in n-dimensional spaces.
package com.brettonw.math;
import com.brettonw.bag.BagArray;
public abstract class ClusterAlgorithm {
protected DataSet dataSet;
protected ClusterAlgorithm (DataSet dataSet) {
this.dataSet = dataSet;
}
public DataSet getDataSet () {
return dataSet;
}
public abstract int getClusterCount ();
public abstract Tuple[] getCluster (int i);
public BagArray export () {
int clusterCount = getClusterCount ();
BagArray bagArray = new BagArray (clusterCount);
for (int i = 0; i < clusterCount; ++i) {
Tuple[] tuples = getCluster (i);
int clusterSize = tuples.length;
BagArray clusterBagArray = new BagArray (clusterSize);
for (Tuple tuple : tuples) {
double[] values = tuple.getValues ();
int valuesSize = values.length;
BagArray valuesBagArray = new BagArray (valuesSize);
for (double value : values) {
valuesBagArray.add (value);
}
clusterBagArray.add (valuesBagArray);
}
bagArray.add (clusterBagArray);
}
return bagArray;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy