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

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

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

Instances.attributeToDoubleArray介绍

[英]Gets the value of all instances in this dataset for a particular attribute. Useful in conjunction with Utils.sort to allow iterating through the dataset in sorted order for some attribute.
[中]获取此数据集中特定属性的所有实例的值。与UTIL结合使用非常有用。排序以允许按某些属性的排序顺序遍历数据集。

代码示例

代码示例来源:origin: com.googlecode.obvious/obviousx-weka

@Override
public double[] attributeToDoubleArray(int arg0) {
 return super.attributeToDoubleArray(arg0);
}

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

/**
 * Helper method that transforma an Instances object to a Matrix object.
 *
 * @param inst The Instances to transform.
 * @return  The resulting Matrix object.
 */
public static Matrix instancesToMatrix(Instances inst){
  double[][] darr = new double[inst.numInstances()][inst.numAttributes()];
  for (int i =0 ; i < inst.numAttributes(); i++) {
    for (int j = 0; j < inst.attributeToDoubleArray(i).length; j++) {
      darr[j][i] = inst.attributeToDoubleArray(i)[j];
    }
  }
  return new Matrix(darr);
}

代码示例来源:origin: Waikato/meka

/**
 * Helper method that transforma an Instances object to a Matrix object.
 *
 * @param inst The Instances to transform.
 * @return  The resulting Matrix object.
 */
public static Matrix instancesToMatrix(Instances inst){
  double[][] darr = new double[inst.numInstances()][inst.numAttributes()];
  for (int i =0 ; i < inst.numAttributes(); i++) {
    for (int j = 0; j < inst.attributeToDoubleArray(i).length; j++) {
      darr[j][i] = inst.attributeToDoubleArray(i)[j];
    }
  }
  return new Matrix(darr);
}

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

/**
 * Calculates the area under the precision-recall curve (AUPRC).
 * 
 * @param tcurve a previously extracted threshold curve Instances.
 * @return the PRC area, or Double.NaN if you don't pass in a ThresholdCurve
 *         generated Instances.
 */
public static double getPRCArea(Instances tcurve) {
 final int n = tcurve.numInstances();
 if (!RELATION_NAME.equals(tcurve.relationName()) || (n == 0)) {
  return Double.NaN;
 }
 final int pInd = tcurve.attribute(PRECISION_NAME).index();
 final int rInd = tcurve.attribute(RECALL_NAME).index();
 final double[] pVals = tcurve.attributeToDoubleArray(pInd);
 final double[] rVals = tcurve.attributeToDoubleArray(rInd);
 double area = 0;
 double xlast = rVals[n - 1];
 // start from the first real p/r pair (not the artificial zero point)
 for (int i = n - 2; i >= 0; i--) {
  double recallDelta = rVals[i] - xlast;
  area += (pVals[i] * recallDelta);
  xlast = rVals[i];
 }
 if (area == 0) {
  return Utils.missingValue();
 }
 return area;
}

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

final double[] tpVals = tcurve.attributeToDoubleArray(tpInd);
final double[] fpVals = tcurve.attributeToDoubleArray(fpInd);

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

/**
 * Calculates the area under the precision-recall curve (AUPRC).
 * 
 * @param tcurve a previously extracted threshold curve Instances.
 * @return the PRC area, or Double.NaN if you don't pass in a ThresholdCurve
 *         generated Instances.
 */
public static double getPRCArea(Instances tcurve) {
 final int n = tcurve.numInstances();
 if (!RELATION_NAME.equals(tcurve.relationName()) || (n == 0)) {
  return Double.NaN;
 }
 final int pInd = tcurve.attribute(PRECISION_NAME).index();
 final int rInd = tcurve.attribute(RECALL_NAME).index();
 final double[] pVals = tcurve.attributeToDoubleArray(pInd);
 final double[] rVals = tcurve.attributeToDoubleArray(rInd);
 double area = 0;
 double xlast = rVals[n - 1];
 // start from the first real p/r pair (not the artificial zero point)
 for (int i = n - 2; i >= 0; i--) {
  double recallDelta = rVals[i] - xlast;
  area += (pVals[i] * recallDelta);
  xlast = rVals[i];
 }
 if (area == 0) {
  return Utils.missingValue();
 }
 return area;
}

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

final double[] tpVals = tcurve.attributeToDoubleArray(tpInd);
final double[] fpVals = tcurve.attributeToDoubleArray(fpInd);

代码示例来源:origin: com.googlecode.obvious/obviousx-weka

@Override
public Object getValue(int rowId, int col) {
 if (!isValueValid(rowId, col)) {
  return null; 
 }
 Attribute att = instances.attribute(col);
 if (att.isNumeric()) {
  return instances.attributeToDoubleArray(col)[rowId];
 } else if (att.isNominal() || att.isString()) {
  return instances.instance(rowId).stringValue(col);
 } else if (att.isDate()) {
  double dateValue = instances.attributeToDoubleArray(col)[rowId];
  return att.formatDate(dateValue);
 }
 return null;
}

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

values = instances.attributeToDoubleArray(m_AttributeIndices[i]);
sortedIndices = Utils.sort(values);

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

values = instances.attributeToDoubleArray(m_AttributeIndices[i]);
sortedIndices = Utils.sort(values);

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

double[] recallVals = tcurve.attributeToDoubleArray(recallInd);
int[] sorted = Utils.sort(recallVals);
double isize = 1.0 / (n - 1);

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

double[] recallVals = tcurve.attributeToDoubleArray(recallInd);
int[] sorted = Utils.sort(recallVals);
double isize = 1.0 / (n - 1);

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

double[][] transformedDataMatrix = 
getTransformedDataMatrix(data, m_ClassIndex);
double[] classValueVector = data.attributeToDoubleArray(m_ClassIndex);

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

m_means[i] = m_trainInstances.meanOrMode(i);
m_stdDevs[i] =
 Math.sqrt(Utils.variance(m_trainInstances.attributeToDoubleArray(i)));

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

m_means[i] = m_trainInstances.meanOrMode(i);
m_stdDevs[i] =
 Math.sqrt(Utils.variance(m_trainInstances.attributeToDoubleArray(i)));

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

Attribute classAttribute = null;
if (classIndex >= 0) {
 classes = instances.attributeToDoubleArray(instances.classIndex());
 classAttribute = (Attribute) instances.classAttribute().copy();
 instances.setClassIndex(-1);

代码示例来源:origin: Waikato/meka

double[] column = labels.attributeToDoubleArray(i);
double sum =0.0;
for(int j = 0; j < column.length; j++){

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

double[] column = labels.attributeToDoubleArray(i);
double sum =0.0;
for(int j = 0; j < column.length; j++){

相关文章

Instances类方法