当前位置: 首页>>代码示例>>Java>>正文


Java CentroidClusterModel.getClusterAssignments方法代码示例

本文整理汇总了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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:30,代码来源:CentroidBasedEvaluator.java

示例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;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:30,代码来源:CentroidBasedEvaluator.java

示例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();
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:38,代码来源:CentroidBasedEvaluator.java

示例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();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:42,代码来源:CentroidBasedEvaluator.java


注:本文中的com.rapidminer.operator.clustering.CentroidClusterModel.getClusterAssignments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。