本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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();
}