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

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

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

Instances.attributeStats介绍

[英]Calculates summary statistics on the values that appear in this set of instances for a specified attribute.
[中]计算指定属性的此实例集中出现的值的摘要统计信息。

代码示例

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

@Override
 public void run() {
  m_AttributeStats[index] = m_Instances.attributeStats(index);
  SwingUtilities.invokeLater(new Runnable() {
   @Override
   public void run() {
    setDerived(index);
    m_StatsTable.sizeColumnsToFit(-1);
    m_StatsTable.revalidate();
    m_StatsTable.repaint();
   }
  });
 }
};

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

@Override
 public void run() {
  m_AttributeStats[index] = m_Instances.attributeStats(index);
  SwingUtilities.invokeLater(new Runnable() {
   @Override
   public void run() {
    setDerived(index);
    m_StatsTable.sizeColumnsToFit(-1);
    m_StatsTable.revalidate();
    m_StatsTable.repaint();
   }
  });
 }
};

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

/**
 * Tells the panel which attribute to visualize.
 * 
 * @param index The index of the attribute
 */
public void setAttribute(int index) {
 synchronized (m_locker) {
  // m_threadRun = true;
  m_threadRun = false;
  m_doneCurrentAttribute = false;
  m_displayCurrentAttribute = true;
  // if(m_hc!=null && m_hc.isAlive()) m_hc.stop();
  m_attribIndex = index;
  if (m_asCache[index] != null) {
   m_as = m_asCache[index];
  } else {
   m_asCache[index] = m_data.attributeStats(index);
   m_as = m_asCache[index];
  }
  // m_as = m_data.attributeStats(m_attribIndex);
  // m_classIndex = m_colorAttrib.getSelectedIndex();
 }
 this.repaint();
 // calcGraph();
}

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

/**
 * Tells the panel which attribute to visualize.
 * 
 * @param index The index of the attribute
 */
public void setAttribute(int index) {
 synchronized (m_locker) {
  // m_threadRun = true;
  m_threadRun = false;
  m_doneCurrentAttribute = false;
  m_displayCurrentAttribute = true;
  // if(m_hc!=null && m_hc.isAlive()) m_hc.stop();
  m_attribIndex = index;
  if (m_asCache[index] != null) {
   m_as = m_asCache[index];
  } else {
   m_asCache[index] = m_data.attributeStats(index);
   m_as = m_asCache[index];
  }
  // m_as = m_data.attributeStats(m_attribIndex);
  // m_classIndex = m_colorAttrib.getSelectedIndex();
 }
 this.repaint();
 // calcGraph();
}

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

private void Initialize(MultiLabelInstances mlData) {
    Instances dataSet = mlData.getDataSet();
    int[] featureIndices = mlData.getFeatureIndices();
    for (int attIndex : featureIndices) {
      Attribute feature = dataSet.attribute(attIndex);
      if (feature.isNumeric()) {
        Stats stats = dataSet.attributeStats(attIndex).numericStats;
        attStats.put(attIndex, new double[]{stats.min, stats.max});
      }
    }
  }
}

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

stats = inst.attributeStats(attIdx);
if (m_Invert) {
 count = stats.nominalCounts.length - m_NumValues;
stats = inst.attributeStats(attIdx);
for (i = 0; i < stats.nominalCounts.length; i++) {
 if ((stats.nominalCounts[i] >= min) && (stats.nominalCounts[i] <= max)

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

/**
 * checks the statistics of the attribute
 */
public void testStats() {
 checkStatistics(
   "MIN", m_Instances.attributeStats(m_AttIndex).numericStats.min);
 checkStatistics(
   "MAX", m_Instances.attributeStats(m_AttIndex).numericStats.max);
 checkStatistics(
   "MEAN", m_Instances.attributeStats(m_AttIndex).numericStats.mean);
 checkStatistics(
   "SD", m_Instances.attributeStats(m_AttIndex).numericStats.stdDev);
 checkStatistics(
   "COUNT", m_Instances.attributeStats(m_AttIndex).numericStats.count);
 checkStatistics(
   "SUM", m_Instances.attributeStats(m_AttIndex).numericStats.sum);
 checkStatistics(
   "SUMSQUARED", m_Instances.attributeStats(m_AttIndex).numericStats.sumSq);
}

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

/**
 * checks the statistics of the attribute
 */
public void testStats() {
 checkStatistics(
   "MIN", m_Instances.attributeStats(m_AttIndex).numericStats.min);
 checkStatistics(
   "MAX", m_Instances.attributeStats(m_AttIndex).numericStats.max);
 checkStatistics(
   "MEAN", m_Instances.attributeStats(m_AttIndex).numericStats.mean);
 checkStatistics(
   "SD", m_Instances.attributeStats(m_AttIndex).numericStats.stdDev);
 checkStatistics(
   "COUNT", m_Instances.attributeStats(m_AttIndex).numericStats.count);
 checkStatistics(
   "SUM", m_Instances.attributeStats(m_AttIndex).numericStats.sum);
 checkStatistics(
   "SUMSQUARED", m_Instances.attributeStats(m_AttIndex).numericStats.sumSq);
}

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

AttributeStats as = instances.attributeStats(i);
if (m_upperBoundMinSupport == 1.0 && maxCount != numInstances) {

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

AttributeStats as = inst.attributeStats(attIndex);
double pIndex = quantile * (inst.numInstances() - as.missingCount);
double mean = as.numericStats.mean;

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

/**
 * Pretty hokey heuristic to try and set t2 distance automatically based on
 * standard deviation
 * 
 * @param trainingBatch the training instances
 * @throws Exception if a problem occurs
 */
protected void setT2T1BasedOnStdDev(Instances trainingBatch) throws Exception {
 double normalizedStdDevSum = 0;
 for (int i = 0; i < trainingBatch.numAttributes(); i++) {
  if (trainingBatch.attribute(i).isNominal()) {
   normalizedStdDevSum += 0.25;
  } else if (trainingBatch.attribute(i).isNumeric()) {
   AttributeStats stats = trainingBatch.attributeStats(i);
   if (trainingBatch.numInstances() - stats.missingCount > 2) {
    double stdDev = stats.numericStats.stdDev;
    double min = stats.numericStats.min;
    double max = stats.numericStats.max;
    if (!Utils.isMissingValue(stdDev) && max - min > 0) {
     stdDev = 0.5 * stdDev / (max - min);
     normalizedStdDevSum += stdDev;
    }
   }
  }
 }
 normalizedStdDevSum = Math.sqrt(normalizedStdDevSum);
 if (normalizedStdDevSum > 0) {
  m_t2 = normalizedStdDevSum;
 }
}

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

/**
 * Pretty hokey heuristic to try and set t2 distance automatically based on
 * standard deviation
 * 
 * @param trainingBatch the training instances
 * @throws Exception if a problem occurs
 */
protected void setT2T1BasedOnStdDev(Instances trainingBatch) throws Exception {
 double normalizedStdDevSum = 0;
 for (int i = 0; i < trainingBatch.numAttributes(); i++) {
  if (trainingBatch.attribute(i).isNominal()) {
   normalizedStdDevSum += 0.25;
  } else if (trainingBatch.attribute(i).isNumeric()) {
   AttributeStats stats = trainingBatch.attributeStats(i);
   if (trainingBatch.numInstances() - stats.missingCount > 2) {
    double stdDev = stats.numericStats.stdDev;
    double min = stats.numericStats.min;
    double max = stats.numericStats.max;
    if (!Utils.isMissingValue(stdDev) && max - min > 0) {
     stdDev = 0.5 * stdDev / (max - min);
     normalizedStdDevSum += stdDev;
    }
   }
  }
 }
 normalizedStdDevSum = Math.sqrt(normalizedStdDevSum);
 if (normalizedStdDevSum > 0) {
  m_t2 = normalizedStdDevSum;
 }
}

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

private void testDistributionSpread_X(double factor) throws Exception {
 AttributeStats origs = m_Instances.attributeStats(1);
 assertNotNull(origs.nominalCounts);
 
 ((SpreadSubsample)m_Filter).setDistributionSpread(factor);
 Instances result = useFilter();
 assertEquals(m_Instances.numAttributes(), result.numAttributes());
 AttributeStats outs = result.attributeStats(1);
 // Check distributions are pretty similar
 assertNotNull(outs.nominalCounts);
 assertEquals(origs.nominalCounts.length, outs.nominalCounts.length);
 int min = outs.nominalCounts[0];
 int max = outs.nominalCounts[0];
 for (int i = 1; i < outs.nominalCounts.length; i++) {
  if (outs.nominalCounts[i] < min) {
   min = outs.nominalCounts[i];
  }
  if (outs.nominalCounts[i] > max) {
   max = outs.nominalCounts[i];
  }
 }
 assertTrue(max / factor <= min);
}

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

public void testNoBias() throws Exception {
 m_Instances.setClassIndex(1);
 AttributeStats origs = m_Instances.attributeStats(1);
 assertNotNull(origs.nominalCounts);
 Instances result = useFilter();
 assertEquals(m_Instances.numAttributes(), result.numAttributes());
 AttributeStats outs = result.attributeStats(1);
 // Check distributions are pretty similar
 assertNotNull(outs.nominalCounts);
 assertEquals(origs.nominalCounts.length, outs.nominalCounts.length);
 for (int i = 0; i < origs.nominalCounts.length; i++) {
  int est = origs.nominalCounts[i] / 2 - 1;
  assertTrue("Counts for value:" + i 
      + " orig:" + origs.nominalCounts[i] 
      + " out50%:" + outs.nominalCounts[i], 
      (est <= outs.nominalCounts[i]) &&
      (outs.nominalCounts[i] <= (est + 3)));
 }
}

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

public void testNoBias() throws Exception {
 m_Instances.setClassIndex(1);
 AttributeStats origs = m_Instances.attributeStats(1);
 assertNotNull(origs.nominalCounts);
 Instances result = useFilter();
 assertEquals(m_Instances.numAttributes(), result.numAttributes());
 AttributeStats outs = result.attributeStats(1);
 // Check distributions are pretty similar
 assertNotNull(outs.nominalCounts);
 assertEquals(origs.nominalCounts.length, outs.nominalCounts.length);
 for (int i = 0; i < origs.nominalCounts.length; i++) {
  int est = origs.nominalCounts[i] / 2 - 1;
  assertTrue("Counts for value:" + i 
      + " orig:" + origs.nominalCounts[i] 
      + " out50%:" + outs.nominalCounts[i], 
      (est <= outs.nominalCounts[i]) &&
      (outs.nominalCounts[i] <= (est + 3)));
 }
}

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

private void testDistributionSpread_X(double factor) throws Exception {
 AttributeStats origs = m_Instances.attributeStats(1);
 assertNotNull(origs.nominalCounts);
 
 ((SpreadSubsample)m_Filter).setDistributionSpread(factor);
 Instances result = useFilter();
 assertEquals(m_Instances.numAttributes(), result.numAttributes());
 AttributeStats outs = result.attributeStats(1);
 // Check distributions are pretty similar
 assertNotNull(outs.nominalCounts);
 assertEquals(origs.nominalCounts.length, outs.nominalCounts.length);
 int min = outs.nominalCounts[0];
 int max = outs.nominalCounts[0];
 for (int i = 1; i < outs.nominalCounts.length; i++) {
  if (outs.nominalCounts[i] < min) {
   min = outs.nominalCounts[i];
  }
  if (outs.nominalCounts[i] > max) {
   max = outs.nominalCounts[i];
  }
 }
 assertTrue(max / factor <= min);
}

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

public void testBiasToUniform() throws Exception {
 m_Instances.setClassIndex(1);
 AttributeStats origs = m_Instances.attributeStats(1);
 assertNotNull(origs.nominalCounts);
 
 ((Resample)m_Filter).setBiasToUniformClass(1.0);
 Instances result = useFilter();
 assertEquals(m_Instances.numAttributes(), result.numAttributes());
 AttributeStats outs = result.attributeStats(1);
 // Check distributions are pretty similar
 assertNotNull(outs.nominalCounts);
 assertEquals(origs.nominalCounts.length, outs.nominalCounts.length);
 int est = (origs.totalCount - origs.missingCount) / origs.distinctCount;
 est = est / 2 - 1;
 for (int i = 0; i < origs.nominalCounts.length; i++) {
  assertTrue("Counts for value:" + i 
      + " orig:" + origs.nominalCounts[i] 
      + " out50%:" + outs.nominalCounts[i]
      + " ~wanted:" + est,
      (est <= outs.nominalCounts[i]) &&
      (outs.nominalCounts[i] <= (est + 3)));
 }
}

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

public void testBiasToUniform() throws Exception {
 m_Instances.setClassIndex(1);
 AttributeStats origs = m_Instances.attributeStats(1);
 assertNotNull(origs.nominalCounts);
 
 ((Resample)m_Filter).setBiasToUniformClass(1.0);
 Instances result = useFilter();
 assertEquals(m_Instances.numAttributes(), result.numAttributes());
 AttributeStats outs = result.attributeStats(1);
 // Check distributions are pretty similar
 assertNotNull(outs.nominalCounts);
 assertEquals(origs.nominalCounts.length, outs.nominalCounts.length);
 int est = (origs.totalCount - origs.missingCount) / origs.distinctCount;
 est = est / 2 - 1;
 for (int i = 0; i < origs.nominalCounts.length; i++) {
  assertTrue("Counts for value:" + i 
      + " orig:" + origs.nominalCounts[i] 
      + " out50%:" + outs.nominalCounts[i]
      + " ~wanted:" + est,
      (est <= outs.nominalCounts[i]) &&
      (outs.nominalCounts[i] <= (est + 3)));
 }
}

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

continue; // skip class
AttributeStats stats = toFilter.attributeStats(i);
if (stats.missingCount == toFilter.numInstances()) {
 attsToDelete[numToDelete++] = i;

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

AttributeStats stats = denormalized.attributeStats(i);
if (denormalized.attribute(i).isNumeric()) {
 NumericStats ns = new NumericStats(denormalized.attribute(i).name());

相关文章

Instances类方法