本文整理了Java中weka.core.Instances.sortBasedOnNominalAttribute()
方法的一些代码示例,展示了Instances.sortBasedOnNominalAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instances.sortBasedOnNominalAttribute()
方法的具体详情如下:
包路径:weka.core.Instances
类名称: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);
内容来源于网络,如有侵权,请联系作者删除!