本文整理了Java中weka.core.Utils.sort()
方法的一些代码示例,展示了Utils.sort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.sort()
方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:sort
[英]Sorts a given array of doubles in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array. NOTE THESE CHANGES: the sort is no longer stable and it doesn't use safe floating-point comparisons anymore. Occurrences of Double.NaN are treated as Double.MAX_VALUE.
[中]按升序对给定的双精度数组进行排序,并返回一个整数数组,其中包含原始数组元素在已排序数组中的位置。注意这些变化:排序不再稳定,不再使用安全的浮点比较。出现双重情况。NaN被视为双重身份。最大值。
代码示例来源:origin: Waikato/meka
public static final int[] sort(int a[]) {
int c[] = Arrays.copyOf(a,a.length);
Utils.sort(c); // @todo: Arrays.sort ?
return c;
}
代码示例来源:origin: net.sf.meka/meka
public static final int[] sort(int a[]) {
int c[] = Arrays.copyOf(a,a.length);
Utils.sort(c); // @todo: Arrays.sort ?
return c;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/meka
public static final Instance deleteAttributesAt(Instance x, int indicesToRemove[]) {//, boolean keep) {
Utils.sort(indicesToRemove);
for(int j = indicesToRemove.length-1; j >= 0; j--) {
x.deleteAttributeAt(indicesToRemove[j]);
}
return x;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/meka
public static final Instances deleteAttributesAt(Instances D, int indicesToRemove[]) {//, boolean keep) {
Utils.sort(indicesToRemove);
for(int j = indicesToRemove.length-1; j >= 0; j--) {
D.deleteAttributeAt(indicesToRemove[j]);
}
return D;
}
代码示例来源:origin: Waikato/meka
/**
* Rank Matrix
*/
public static int[][] rankMatrix(List<EvaluationStatistics> stats, String measurement) {
double V[][] = valueMatrix(stats,measurement);
int N = V.length;
int k = V[0].length;
int R[][] = new int[N][k];
for (int i = 0; i < N; i++) {
int indices[] = Utils.sort(V[i]);
// add 1 to each
for (int j = 0; j < k; j++) {
R[i][indices[j]] = (j+1);
}
}
return R;
}
代码示例来源:origin: net.sf.meka/meka
/**
* Rank Matrix
*/
public static int[][] rankMatrix(List<EvaluationStatistics> stats, String measurement) {
double V[][] = valueMatrix(stats,measurement);
int N = V.length;
int k = V[0].length;
int R[][] = new int[N][k];
for (int i = 0; i < N; i++) {
int indices[] = Utils.sort(V[i]);
// add 1 to each
for (int j = 0; j < k; j++) {
R[i][indices[j]] = (j+1);
}
}
return R;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Check whether the two integer vectors equal to each other Two integer
* vectors are equal if all the elements are the same, regardless of the
* order of the elements
*
* @param b another integer vector
* @return whether they are equal
*/
private boolean equal(DynamicIntArray b) {
if ((b == null) || (size() != b.size())) {
return false;
}
int size = size();
// Only values matter, order does not matter
int[] sorta = Utils.sort(m_Objects), sortb = Utils.sort(b.m_Objects);
for (int j = 0; j < size; j++) {
if (m_Objects[sorta[j]] != b.m_Objects[sortb[j]]) {
return false;
}
}
return true;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Check whether the two integer vectors equal to each other Two integer
* vectors are equal if all the elements are the same, regardless of the
* order of the elements
*
* @param b another integer vector
* @return whether they are equal
*/
private boolean equal(DynamicIntArray b) {
if ((b == null) || (size() != b.size())) {
return false;
}
int size = size();
// Only values matter, order does not matter
int[] sorta = Utils.sort(m_Objects), sortb = Utils.sort(b.m_Objects);
for (int j = 0; j < size; j++) {
if (m_Objects[sorta[j]] != b.m_Objects[sortb[j]]) {
return false;
}
}
return true;
}
代码示例来源:origin: net.sf.meka/meka
public static double L_RankLoss(int y[], double rpred[]) {
// works with missing
double[][] aligned = align(y, rpred);
y = toIntArray(aligned[0]);
rpred = aligned[1];
int r[] = Utils.sort(rpred);
return L_RankLoss(y, r);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/linearForwardSelection
int[] ranking = Utils.sort(merit);
代码示例来源:origin: Waikato/meka
public static double L_RankLoss(int y[], double rpred[]) {
// works with missing
double[][] aligned = align(y, rpred);
y = toIntArray(aligned[0]);
rpred = aligned[1];
int r[] = Utils.sort(rpred);
return L_RankLoss(y, r);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* returns the ranking in a string representation.
*
* @return the ranking
*/
public String toStringRanking() {
String result;
int[] ranking;
int i;
int curr;
if (m_RankingWins == null)
return "-ranking data not set-";
result = ">-<,>,<,Resultset\n";
ranking = Utils.sort(m_RankingDiff);
for (i = getColCount() - 1; i >= 0; i--) {
curr = ranking[i];
if (getColHidden(curr))
continue;
result += m_RankingDiff[curr] + ","
+ m_RankingWins[curr] + ","
+ m_RankingLosses[curr] + ","
+ removeFilterName(m_ColNames[curr]) + "\n";
}
return result;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
+ "\\\\\n\\hline\n";
ranking = Utils.sort(m_RankingDiff);
for (i = getColCount() - 1; i >= 0; i--) {
curr = ranking[i];
代码示例来源:origin: Waikato/weka-trunk
/**
* returns the ranking in a string representation.
*
* @return the ranking
*/
public String toStringRanking() {
String result;
int[] ranking;
int i;
int curr;
if (m_RankingWins == null)
return "-ranking data not set-";
result = ">-<,>,<,Resultset\n";
ranking = Utils.sort(m_RankingDiff);
for (i = getColCount() - 1; i >= 0; i--) {
curr = ranking[i];
if (getColHidden(curr))
continue;
result += m_RankingDiff[curr] + ","
+ m_RankingWins[curr] + ","
+ m_RankingLosses[curr] + ","
+ removeFilterName(m_ColNames[curr]) + "\n";
}
return result;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
+ "</tr>\n";
ranking = Utils.sort(m_RankingDiff);
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Gets the index of the instance with the closest threshold value to the
* desired target
*
* @param tcurve a set of instances that have been generated by this class
* @param threshold the target threshold
* @return the index of the instance that has threshold closest to the target,
* or -1 if this could not be found (i.e. no data, or bad threshold
* target)
*/
public static int getThresholdInstance(Instances tcurve, double threshold) {
if (!RELATION_NAME.equals(tcurve.relationName())
|| (tcurve.numInstances() == 0) || (threshold < 0) || (threshold > 1.0)) {
return -1;
}
if (tcurve.numInstances() == 1) {
return 0;
}
double[] tvals = tcurve.attributeToDoubleArray(tcurve.numAttributes() - 1);
int[] sorted = Utils.sort(tvals);
return binarySearch(sorted, tvals, threshold);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Gets the index of the instance with the closest threshold value to the
* desired target
*
* @param tcurve a set of instances that have been generated by this class
* @param threshold the target threshold
* @return the index of the instance that has threshold closest to the target,
* or -1 if this could not be found (i.e. no data, or bad threshold
* target)
*/
public static int getThresholdInstance(Instances tcurve, double threshold) {
if (!RELATION_NAME.equals(tcurve.relationName())
|| (tcurve.numInstances() == 0) || (threshold < 0) || (threshold > 1.0)) {
return -1;
}
if (tcurve.numInstances() == 1) {
return 0;
}
double[] tvals = tcurve.attributeToDoubleArray(tcurve.numAttributes() - 1);
int[] sorted = Utils.sort(tvals);
return binarySearch(sorted, tvals, threshold);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
int[] sortedIndices = Utils.sort(weights);
代码示例来源:origin: com.googlecode.obvious/obviousx-weka
int [] sorted = Utils.sort(attVals);
int currentCount = 0;
double prev = Instance.missingValue();
代码示例来源:origin: Waikato/weka-trunk
m_Indices[j] = Utils.sort(avgClassValues[j]);
内容来源于网络,如有侵权,请联系作者删除!