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

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

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

Utils.kthSmallestValue介绍

[英]Returns the kth-smallest value in the array
[中]

代码示例

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

double[] actualResults = new double[numResults];
System.arraycopy(results, 0, actualResults, 0, numResults);
return Utils.kthSmallestValue(actualResults, actualResults.length / 2);

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

double[] actualResults = new double[numResults];
System.arraycopy(results, 0, actualResults, 0, numResults);
return Utils.kthSmallestValue(actualResults, actualResults.length / 2);

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

System.out.println("Min index (ints): " + Utils.minIndex(ints));
System.out.println("Median (doubles): "
 + Utils.kthSmallestValue(doubles, doubles.length / 2));
System.out.println("Median (ints): "
 + Utils.kthSmallestValue(ints, ints.length / 2));

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

System.out.println("Min index (ints): " + Utils.minIndex(ints));
System.out.println("Median (doubles): "
 + Utils.kthSmallestValue(doubles, doubles.length / 2));
System.out.println("Median (ints): "
 + Utils.kthSmallestValue(ints, ints.length / 2));

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

/**
 * Returns the kth-smallest attribute value of a numeric attribute. NOTE
 * CHANGE: Missing values (NaN values) are now treated as Double.MAX_VALUE.
 * Also, the order of the instances in the data is no longer affected.
 * 
 * @param attIndex the attribute's index
 * @param k the value of k
 * @return the kth-smallest value
 */
public double kthSmallestValue(int attIndex, int k) {
 if (!attribute(attIndex).isNumeric()) {
  throw new IllegalArgumentException(
   "Instances: attribute must be numeric to compute kth-smallest value.");
 }
 if ((k < 1) || (k > numInstances())) {
  throw new IllegalArgumentException(
   "Instances: value for k for computing kth-smallest value too large.");
 }
 double[] vals = new double[numInstances()];
 for (int i = 0; i < vals.length; i++) {
  double val = instance(i).value(attIndex);
  if (Utils.isMissingValue(val)) {
   vals[i] = Double.MAX_VALUE;
  } else {
   vals[i] = val;
  }
 }
 return Utils.kthSmallestValue(vals, k);
}

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

/**
 * Returns the kth-smallest attribute value of a numeric attribute. NOTE
 * CHANGE: Missing values (NaN values) are now treated as Double.MAX_VALUE.
 * Also, the order of the instances in the data is no longer affected.
 * 
 * @param attIndex the attribute's index
 * @param k the value of k
 * @return the kth-smallest value
 */
public double kthSmallestValue(int attIndex, int k) {
 if (!attribute(attIndex).isNumeric()) {
  throw new IllegalArgumentException(
   "Instances: attribute must be numeric to compute kth-smallest value.");
 }
 if ((k < 1) || (k > numInstances())) {
  throw new IllegalArgumentException(
   "Instances: value for k for computing kth-smallest value too large.");
 }
 double[] vals = new double[numInstances()];
 for (int i = 0; i < vals.length; i++) {
  double val = instance(i).value(attIndex);
  if (Utils.isMissingValue(val)) {
   vals[i] = Double.MAX_VALUE;
  } else {
   vals[i] = val;
  }
 }
 return Utils.kthSmallestValue(vals, k);
}

相关文章