Package weka.core

Examples of weka.core.AttributeStats


      Instances toFilter = getInputFormat();
      int[] attsToDelete = new int[toFilter.numAttributes()];
      int numToDelete = 0;
      for(int i = 0; i < toFilter.numAttributes(); i++) {
  if (i==toFilter.classIndex()) continue; // skip class
  AttributeStats stats = toFilter.attributeStats(i);
  if (stats.distinctCount < 2) {
    // remove constant attributes
    attsToDelete[numToDelete++] = i;
  } else if (toFilter.attribute(i).isNominal()) {
    // remove nominal attributes that vary too much
View Full Code Here


    int removeCount = 0;
    boolean first = true;
    int maxCount = 0;
   
    for (int i=0;i<instances.numAttributes();i++) {
      AttributeStats as = instances.attributeStats(i);
      if (m_upperBoundMinSupport == 1.0 && maxCount != numInstances) {
  // see if we can decrease this by looking for the most frequent value
  int [] counts = as.nominalCounts;
  if (counts[Utils.maxIndex(counts)] > maxCount) {
    maxCount = counts[Utils.maxIndex(counts)];
View Full Code Here

             boolean delete) {

      if (m_attStats == null) {
  m_attStats = new AttributeStats[m_numAttributes];
  for (int i = 0; i < m_numAttributes; i++) {
    m_attStats[i] = new AttributeStats();
    if (m_clusterInstances.attribute(i).isNominal()) {
      m_attStats[i].nominalCounts =
        new int [m_clusterInstances.attribute(i).numValues()];
    } else {
      m_attStats[i].numericStats = new Stats();
View Full Code Here

    int removeCount = 0;
    boolean first = true;
    int maxCount = 0;
   
    for (int i=0;i<instances.numAttributes();i++) {
      AttributeStats as = instances.attributeStats(i);
      if (m_upperBoundMinSupport == 1.0 && maxCount != numInstances) {
  // see if we can decrease this by looking for the most frequent value
  int [] counts = as.nominalCounts;
  if (counts[Utils.maxIndex(counts)] > maxCount) {
    maxCount = counts[Utils.maxIndex(counts)];
View Full Code Here

    int      k;
    int      l;
    int      i;
    int      n;
    int      m;
    AttributeStats  stats;
    Attribute    att;
   
    result = getOutputFormat();

    // initialize attribute statistics
View Full Code Here

    }
    assertEquals(origWeight, outWeight, TOLERANCE);
  }

  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];
View Full Code Here

                 - (int) (m_Instances.numInstances() * 20.0 / 100),  result.numInstances());
  }

  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++) {
View Full Code Here

    }
  }

  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;
View Full Code Here

    *
    * @param inst the Instances to determine the values from which are kept 
    */
   public void determineValues(Instances inst) {
      int          i;
      AttributeStats    stats;
      int          attIdx;
      int          min;
      int          max;
      int          count;

View Full Code Here

   *
   * @param index  the index of the attribute
   */
  protected void setDerived(int index) {
   
    AttributeStats as = m_AttributeStats[index];
    long percent = Math.round(100.0 * as.missingCount / as.totalCount);
    m_MissingLab.setText("" + as.missingCount + " (" + percent + "%)");
    percent = Math.round(100.0 * as.uniqueCount / as.totalCount);
    m_UniqueLab.setText("" + as.uniqueCount + " (" + percent + "%)");
    m_DistinctLab.setText("" + as.distinctCount);
View Full Code Here

TOP

Related Classes of weka.core.AttributeStats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.