weka.core.Utils.stableSort()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中weka.core.Utils.stableSort()方法的一些代码示例,展示了Utils.stableSort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.stableSort()方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:stableSort

Utils.stableSort介绍

[英]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. The sort is stable (Equal elements remain in their original order.) Occurrences of Double.NaN are treated as Double.MAX_VALUE
[中]按升序对给定的双精度数组进行排序,并返回一个整数数组,其中包含原始数组元素在已排序数组中的位置。排序是稳定的(相等的元素保持其原始顺序。)出现双重情况。NaN被视为双重身份。最大值

代码示例

代码示例来源:origin: net.sf.meka.thirdparty/mulan

/**
 * Creates a ranking form specified values/confidences.
 * 
 * @param values the values/confidences to be converted to ranking
 * @return the ranking of given values/confidences
 */
public static int[] ranksFromValues(double[] values) {
  int[] temp = weka.core.Utils.stableSort(values);
  int[] ranks = new int[values.length];
  for (int i = 0; i < values.length; i++) {
    ranks[temp[i]] = values.length - i;
  }
  return ranks;
}

代码示例来源:origin: net.sf.meka.thirdparty/mulan

/**
 * Returns the indices of the labels that have the strongest phi correlation
 * with the label which is given as a parameter. The second parameter is
 * the number of labels that will be returned.
 *
 * @param labelIndex
 * @param k
 * @return the indices of the k most correlated labels
 */
public int[] topPhiCorrelatedLabels(int labelIndex, int k) {
  //create a new array containing the absolute values of the original array
  double[] absCorrelations = new double[numLabels];
  for (int i = 0; i < numLabels; i++) {
    absCorrelations[i] = Math.abs(phi[labelIndex][i]);
  }
  //sort the array of correlations
  int[] sorted = Utils.stableSort(absCorrelations);
  int[] topPhiCorrelated = new int[k + 1];
  //the k last values of the sorted array are the indices of the top k correlated labels
  for (int i = 0; i < k; i++) {
    topPhiCorrelated[i] = sorted[numLabels - 1 - i];
  }
  // one more for the class
  topPhiCorrelated[k] = numLabels;
  return topPhiCorrelated;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Sorts the instances in the dataset by the run number.
 * 
 * @param runColumn a value of type 'int'
 */
public void sort(int runColumn) {
 double[] runNums = new double[m_Dataset.size()];
 for (int j = 0; j < runNums.length; j++) {
  runNums[j] = m_Dataset.get(j).value(runColumn);
 }
 int[] index = Utils.stableSort(runNums);
 ArrayList<Instance> newDataset = new ArrayList<Instance>(runNums.length);
 for (int element : index) {
  newDataset.add(m_Dataset.get(element));
 }
 m_Dataset = newDataset;
}

代码示例来源:origin: net.sf.meka.thirdparty/mulan

boolean[] bipartition = new boolean[numLabels];
int[] sortedIndices = weka.core.Utils.stableSort(confidences);
double[] sortedConfidences = Arrays.copyOfRange(confidences, 0, confidences.length);
Arrays.sort(sortedConfidences);

代码示例来源:origin: Waikato/weka-trunk

/**
 * Sorts the instances in the dataset by the run number.
 * 
 * @param runColumn a value of type 'int'
 */
public void sort(int runColumn) {
 double[] runNums = new double[m_Dataset.size()];
 for (int j = 0; j < runNums.length; j++) {
  runNums[j] = m_Dataset.get(j).value(runColumn);
 }
 int[] index = Utils.stableSort(runNums);
 ArrayList<Instance> newDataset = new ArrayList<Instance>(runNums.length);
 for (int element : index) {
  newDataset.add(m_Dataset.get(element));
 }
 m_Dataset = newDataset;
}

代码示例来源:origin: net.sf.meka.thirdparty/mulan

boolean[] bipartition = new boolean[numLabels];
int[] indices = Utils.stableSort(confidences);

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

.support()) * (-1);
indices = Utils.stableSort(supports);
for (int i = 0; i < (j + 1); i++) {
 sortedRuleSet[0].add(m_allTheRules[0].get(indices[j - i]));
  .doubleValue();
indices = Utils.stableSort(confidences);
for (int i = sortedRuleSet[0].size() - 1; (i >= (sortedRuleSet[0].size() - m_numRules))
 && (i >= 0); i--) {

代码示例来源:origin: Waikato/weka-trunk

.support()) * (-1);
indices = Utils.stableSort(supports);
for (int i = 0; i < (j + 1); i++) {
 sortedRuleSet[0].add(m_allTheRules[0].get(indices[j - i]));
  .doubleValue();
indices = Utils.stableSort(confidences);
for (int i = sortedRuleSet[0].size() - 1; (i >= (sortedRuleSet[0].size() - m_numRules))
 && (i >= 0); i--) {

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

sorted = Utils.stableSort(doubles);
for (int i = 0; i < doubles.length; i++) {
 System.out.print(sorted[i] + " ");

代码示例来源:origin: Waikato/weka-trunk

sorted = Utils.stableSort(doubles);
for (int i = 0; i < doubles.length; i++) {
 System.out.print(sorted[i] + " ");

代码示例来源:origin: Waikato/weka-trunk

/**
 * Sorts the instances based on an attribute, using a stable sort. For numeric attributes,
 * instances are sorted in ascending order. For nominal attributes, instances
 * are sorted based on the attribute label ordering specified in the header.
 * Instances with missing values for the attribute are placed at the end of
 * the dataset.
 * 
 * @param attIndex the attribute's index (index starts with 0)
 */
public void stableSort(int attIndex) {
 if (!attribute(attIndex).isNominal()) {
  // Use quicksort from Utils class for sorting
  double[] vals = new double[numInstances()];
  Instance[] backup = new Instance[vals.length];
  for (int i = 0; i < vals.length; i++) {
   Instance inst = instance(i);
   backup[i] = inst;
   vals[i] = inst.value(attIndex);
  }
  int[] sortOrder = Utils.stableSort(vals);
  for (int i = 0; i < vals.length; i++) {
   m_Instances.set(i, backup[sortOrder[i]]);
  }
 } else {
  sortBasedOnNominalAttribute(attIndex);
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Sorts the instances based on an attribute, using a stable sort. For numeric attributes,
 * instances are sorted in ascending order. For nominal attributes, instances
 * are sorted based on the attribute label ordering specified in the header.
 * Instances with missing values for the attribute are placed at the end of
 * the dataset.
 * 
 * @param attIndex the attribute's index (index starts with 0)
 */
public void stableSort(int attIndex) {
 if (!attribute(attIndex).isNominal()) {
  // Use quicksort from Utils class for sorting
  double[] vals = new double[numInstances()];
  Instance[] backup = new Instance[vals.length];
  for (int i = 0; i < vals.length; i++) {
   Instance inst = instance(i);
   backup[i] = inst;
   vals[i] = inst.value(attIndex);
  }
  int[] sortOrder = Utils.stableSort(vals);
  for (int i = 0; i < vals.length; i++) {
   m_Instances.set(i, backup[sortOrder[i]]);
  }
 } else {
  sortBasedOnNominalAttribute(attIndex);
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

int[] sortedIndexes = Utils.stableSort(densities);

代码示例来源:origin: Waikato/weka-trunk

int[] sortedIndexes = Utils.stableSort(densities);

代码示例来源:origin: com.entopix/maui

int[] sortedIndices = Utils.stableSort(vals);
for (int i = 0; i < vals.length; i++) {
  newVector.addElement(vector.elementAt(sortedIndices[i]));
sortedIndices = Utils.stableSort(vals);
for (int i = 0; i < vals.length; i++) {
  newVector.addElement(vector.elementAt(sortedIndices[i]));
sortedIndices = Utils.stableSort(vals);
for (int i = 0; i < vals.length; i++) {
  newVector.addElement(vector.elementAt(sortedIndices[i]));

代码示例来源:origin: Waikato/weka-trunk

int[] indices = Utils.stableSort(predictedDistribution);
double sum = 0, sizeOfRegions = 0;
for (int i = predictedDistribution.length - 1; i >= 0; i--) {

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

int[] indices = Utils.stableSort(predictedDistribution);
double sum = 0, sizeOfRegions = 0;
for (int i = predictedDistribution.length - 1; i >= 0; i--) {

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

vals[i] = isAttribute(columnIndex) ? inst.value(getAttributeIndex(columnIndex)) : inst.weight();
int[] sortOrder = Utils.stableSort(vals);
for (int i = 0; i < vals.length; i++) {
 m_Data.set(i, backup[sortOrder[i]]);

代码示例来源:origin: Waikato/weka-trunk

vals[i] = isAttribute(columnIndex) ? inst.value(getAttributeIndex(columnIndex)) : inst.weight();
int[] sortOrder = Utils.stableSort(vals);
for (int i = 0; i < vals.length; i++) {
 m_Data.set(i, backup[sortOrder[i]]);

相关文章