weka.core.Instances.sortBasedOnNominalAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(90)

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

Instances.sortBasedOnNominalAttribute介绍

[英]Sorts a nominal attribute (stable, linear-time sort). Instances are sorted based on the attribute label ordering specified in the header.
[中]对标称属性进行排序(稳定、线性时间排序)。实例根据标头中指定的属性标签顺序进行排序。

代码示例

代码示例来源: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: 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

sortBasedOnNominalAttribute(attIndex);

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

sortBasedOnNominalAttribute(attIndex);

相关文章

Instances类方法