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


Java EuclideanDistance类代码示例

本文整理汇总了Java中com.rapidminer.tools.math.similarity.numerical.EuclideanDistance的典型用法代码示例。如果您正苦于以下问题:Java EuclideanDistance类的具体用法?Java EuclideanDistance怎么用?Java EuclideanDistance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EuclideanDistance类属于com.rapidminer.tools.math.similarity.numerical包,在下文中一共展示了EuclideanDistance类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: similarityExampleSetActivatedTest

import com.rapidminer.tools.math.similarity.numerical.EuclideanDistance; //导入依赖的package包/类
@Test
public void similarityExampleSetActivatedTest() throws UserError {
	ParameterService.setParameterValue(RapidMiner.PROPERTY_RAPIDMINER_SYSTEM_LEGACY_DATA_MGMT, String.valueOf(false));

	ExampleSet simpleExampleSet = ExampleSets.from(attribute1, attribute2, attribute3, attribute4).withBlankSize(ROWS)
			.withRole(attribute1, Attributes.ID_NAME).build();
	ExampleSet similarityExampleSet = new SimilarityExampleSet(simpleExampleSet, new EuclideanDistance());

	// a {@link SimilarityExampleSet} has no example table and no stored values so we have to
	// remove attributes from the simpleExampleSet
	setValues(simpleExampleSet);
	removeAttributes(simpleExampleSet);
	ExampleTable oldTable = simpleExampleSet.getExampleTable();

	similarityExampleSet.cleanup();

	testForActivated(simpleExampleSet, oldTable);
	testValues(simpleExampleSet);
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:20,代码来源:ColumnCleanupTest.java

示例2: similarityExampleSetDeactivatedTest

import com.rapidminer.tools.math.similarity.numerical.EuclideanDistance; //导入依赖的package包/类
@Test
public void similarityExampleSetDeactivatedTest() throws UserError {
	ParameterService.setParameterValue(RapidMiner.PROPERTY_RAPIDMINER_SYSTEM_LEGACY_DATA_MGMT, String.valueOf(true));

	ExampleSet simpleExampleSet = ExampleSets.from(attribute1, attribute2, attribute3, attribute4).withBlankSize(ROWS)
			.withRole(attribute1, Attributes.ID_NAME).build();
	ExampleSet similarityExampleSet = new SimilarityExampleSet(simpleExampleSet, new EuclideanDistance());

	// a {@link SimilarityExampleSet} has no example table and no stored values so we have to
	// remove attributes from the simpleExampleSet
	setValues(simpleExampleSet);
	removeAttributes(simpleExampleSet);
	ExampleTable oldTable = simpleExampleSet.getExampleTable();

	similarityExampleSet.cleanup();

	testForDeactivated(simpleExampleSet, oldTable);
	testValues(simpleExampleSet);
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:20,代码来源:ColumnCleanupTest.java

示例3: getDaviesBouldin

import com.rapidminer.tools.math.similarity.numerical.EuclideanDistance; //导入依赖的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.tools.math.similarity.numerical.EuclideanDistance; //导入依赖的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.tools.math.similarity.numerical.EuclideanDistance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。