本文整理汇总了Java中com.rapidminer.tools.math.som.KohonenNet.getDistance方法的典型用法代码示例。如果您正苦于以下问题:Java KohonenNet.getDistance方法的具体用法?Java KohonenNet.getDistance怎么用?Java KohonenNet.getDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.tools.math.som.KohonenNet
的用法示例。
在下文中一共展示了KohonenNet.getDistance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPMatrix
import com.rapidminer.tools.math.som.KohonenNet; //导入方法依赖的package包/类
private double[][] getPMatrix(KohonenNet net, RandomDataContainer data, int[] dimensions) {
// calculating real paretoradius
int n = data.countData();
double optimalMedian = 0.2013 * n;
double estimatedRadius = 0;
// calculating distances between every example
double[] distances = new double[n * n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
distances[i * n + j] = net.getDistance(data.get(i), data.get(j));
}
}
Arrays.sort(distances);
double percentilSetDifference = Double.POSITIVE_INFINITY;
// finding percentil, closest to paretoradius
double radius;
for (int percentil = 0; percentil < 100; percentil++) {
int[] nn = new int[n];
radius = distances[(int) Math.round((double) (percentil * n * n) / 100)];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (net.getDistance(data.get(i), data.get(j)) <= radius) {
nn[i]++;
}
}
}
Arrays.sort(nn);
int currentMedian = nn[n / 2] - 1; // point himself is no real neighbour, but always
// nearest point
if (Math.abs(currentMedian - optimalMedian) <= percentilSetDifference) {
percentilSetDifference = Math.abs(currentMedian - optimalMedian);
} else {
estimatedRadius = radius;
break;
}
}
// generating P Matrix
double[][] pMatrix = new double[dimensions[0]][dimensions[1]];
for (int i = 0; i < dimensions[0]; i++) {
for (int j = 0; j < dimensions[1]; j++) {
double nodeWeight[] = net.getNodeWeights(new int[] { i, j });
int neighbours = 0;
for (int x = 0; x < n; x++) {
if (net.getDistance(data.get(x), nodeWeight) < estimatedRadius) {
neighbours++;
}
}
pMatrix[i][j] = (double) neighbours / n;
}
}
return pMatrix;
}
示例2: getPMatrix
import com.rapidminer.tools.math.som.KohonenNet; //导入方法依赖的package包/类
private double[][] getPMatrix(KohonenNet net, RandomDataContainer data, int[] dimensions) {
// calculating real paretoradius
int n = data.countData();
double optimalMedian = 0.2013 * n;
double estimatedRadius = 0;
// calculating distances between every example
double[] distances = new double[n * n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
distances[i * n + j] = net.getDistance(data.get(i), data.get(j));
}
}
Arrays.sort(distances);
double percentilSetDifference = Double.POSITIVE_INFINITY;
// finding percentil, closest to paretoradius
double radius;
for (int percentil = 0; percentil < 100; percentil++) {
int[] nn = new int[n];
radius = distances[(int) Math.round(((double) (percentil * n * n)) / 100)];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (net.getDistance(data.get(i), data.get(j)) <= radius) {
nn[i]++;
}
}
}
Arrays.sort(nn);
int currentMedian = nn[n / 2] - 1; //point himself is no real neighbour, but always nearest point
if (Math.abs(currentMedian - optimalMedian) <= percentilSetDifference) {
percentilSetDifference = Math.abs(currentMedian - optimalMedian);
} else {
estimatedRadius = radius;
break;
}
}
// generating P Matrix
double[][] pMatrix = new double[dimensions[0]][dimensions[1]];
for (int i = 0; i < dimensions[0]; i++) {
for (int j = 0; j < dimensions[1]; j++) {
double nodeWeight[] = net.getNodeWeights(new int[] { i, j });
int neighbours = 0;
for (int x = 0; x < n; x++) {
if (net.getDistance(data.get(x), nodeWeight) < estimatedRadius) {
neighbours++;
}
}
pMatrix[i][j] = ((double) neighbours) / n;
}
}
return pMatrix;
}