本文整理汇总了Java中com.rapidminer.operator.clustering.CentroidClusterModel.getClusterAssignments方法的典型用法代码示例。如果您正苦于以下问题:Java CentroidClusterModel.getClusterAssignments方法的具体用法?Java CentroidClusterModel.getClusterAssignments怎么用?Java CentroidClusterModel.getClusterAssignments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.operator.clustering.CentroidClusterModel
的用法示例。
在下文中一共展示了CentroidClusterModel.getClusterAssignments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAverageWithinDistance
import com.rapidminer.operator.clustering.CentroidClusterModel; //导入方法依赖的package包/类
private double[] getAverageWithinDistance(CentroidClusterModel model, ExampleSet exampleSet) throws OperatorException {
DistanceMeasure measure = new SquaredEuclideanDistance();
measure.init(exampleSet);
int numberOfClusters = model.getNumberOfClusters();
// counting distances within
double[] result = new double[numberOfClusters + 1];
int[] clusterSizes = new int[numberOfClusters];
int[] clusterIndices = model.getClusterAssignments(exampleSet);
int i = 0;
for (Example example : exampleSet) {
clusterSizes[clusterIndices[i]]++;
result[clusterIndices[i]] += measure.calculateDistance(example, model.getCentroidCoordinates(clusterIndices[i]));
i++;
}
// averaging by cluster sizes and sum over all
int totalSize = 0;
for (i = 0; i < numberOfClusters; i++) {
result[numberOfClusters] += result[i];
result[i] /= clusterSizes[i];
totalSize += clusterSizes[i];
}
result[numberOfClusters] /= totalSize;
return result;
}
示例2: getAverageWithinDistance
import com.rapidminer.operator.clustering.CentroidClusterModel; //导入方法依赖的package包/类
private double[] getAverageWithinDistance(CentroidClusterModel model, ExampleSet exampleSet) throws OperatorException {
DistanceMeasure measure = new SquaredEuclideanDistance();
measure.init(exampleSet);
int numberOfClusters = model.getNumberOfClusters();
// counting distances within
double[] result = new double[numberOfClusters + 1];
int[] clusterSizes = new int[numberOfClusters];
int[] clusterIndices = model.getClusterAssignments(exampleSet);
int i = 0;
for (Example example: exampleSet) {
clusterSizes[clusterIndices[i]]++;
result[clusterIndices[i]] += measure.calculateDistance(example, model.getCentroidCoordinates(clusterIndices[i]));
i++;
}
// averaging by cluster sizes and sum over all
int totalSize = 0;
for (i = 0; i < numberOfClusters; i++) {
result[numberOfClusters] += result[i];
result[i] /= clusterSizes[i];
totalSize += clusterSizes[i];
}
result[numberOfClusters] /= totalSize;
return result;
}
示例3: getDaviesBouldin
import com.rapidminer.operator.clustering.CentroidClusterModel; //导入方法依赖的package包/类
private double getDaviesBouldin(CentroidClusterModel model, ExampleSet exampleSet) throws OperatorException {
DistanceMeasure measure = new EuclideanDistance();
measure.init(exampleSet);
int numberOfClusters = model.getNumberOfClusters();
// counting distances within
double[] withinClusterDistance = new double[numberOfClusters];
int[] clusterSizes = new int[numberOfClusters];
int[] clusterIndices = model.getClusterAssignments(exampleSet);
int i = 0;
for (Example example: exampleSet) {
clusterSizes[clusterIndices[i]]++;
withinClusterDistance[clusterIndices[i]] += measure.calculateDistance(example, model.getCentroidCoordinates(clusterIndices[i]));
i++;
}
// averaging by cluster sizes and sum over all
for (i = 0; i < numberOfClusters; i++) {
withinClusterDistance[i] /= clusterSizes[i];
}
double result = 0.0;
for (i = 0; i < numberOfClusters; i++) {
double max = Double.NEGATIVE_INFINITY;
for (int j = 0; j < numberOfClusters; j++)
if (i != j) {
double val = (withinClusterDistance[i] + withinClusterDistance[j]) / measure.calculateDistance(model.getCentroidCoordinates(i), model.getCentroidCoordinates(j));
if (val > max)
max = val;
}
result = result + max;
}
return result / model.getNumberOfClusters();
}
示例4: getDaviesBouldin
import com.rapidminer.operator.clustering.CentroidClusterModel; //导入方法依赖的package包/类
private double getDaviesBouldin(CentroidClusterModel model, ExampleSet exampleSet) throws OperatorException {
DistanceMeasure measure = new EuclideanDistance();
measure.init(exampleSet);
int numberOfClusters = model.getNumberOfClusters();
// counting distances within
double[] withinClusterDistance = new double[numberOfClusters];
int[] clusterSizes = new int[numberOfClusters];
int[] clusterIndices = model.getClusterAssignments(exampleSet);
int i = 0;
for (Example example : exampleSet) {
clusterSizes[clusterIndices[i]]++;
withinClusterDistance[clusterIndices[i]] += measure.calculateDistance(example,
model.getCentroidCoordinates(clusterIndices[i]));
i++;
}
// averaging by cluster sizes and sum over all
for (i = 0; i < numberOfClusters; i++) {
withinClusterDistance[i] /= clusterSizes[i];
}
double result = 0.0;
for (i = 0; i < numberOfClusters; i++) {
double max = Double.NEGATIVE_INFINITY;
for (int j = 0; j < numberOfClusters; j++) {
if (i != j) {
double val = (withinClusterDistance[i] + withinClusterDistance[j])
/ measure.calculateDistance(model.getCentroidCoordinates(i), model.getCentroidCoordinates(j));
if (val > max) {
max = val;
}
}
}
result = result + max;
}
return result / model.getNumberOfClusters();
}