Package weka.core

Examples of weka.core.Instances.attribute()


  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
    double variancePercent = (double) stats.distinctCount
      / (double)(stats.totalCount - stats.missingCount) * 100.0;
    if (variancePercent > m_maxVariancePercentage) {
        attsToDelete[numToDelete++] = i;
View Full Code Here


  // add attributes
  for (n = 0; n < processed.numAttributes(); n++) {
    if (n == processed.classIndex())
      continue;
    atts.add((Attribute) processed.attribute(n).copy());
  }
      }

      // add unused attributes
      if (!getRemoveUnused()) {
View Full Code Here

    int c;
    while ((c = is.read()) != -1) {
      txtStr.append((char) c);
    }
   
    newInst[0] = (double) data.attribute(0).addStringValue(txtStr.toString());
    if (m_OutputFilename)
      newInst[1] = (double) data.attribute(1).addStringValue(subdirPath + File.separator + files[j]);
    newInst[data.classIndex()] = (double) k;
    data.add(new DenseInstance(1.0, newInst));
          is.close();
View Full Code Here

      txtStr.append((char) c);
    }
   
    newInst[0] = (double) data.attribute(0).addStringValue(txtStr.toString());
    if (m_OutputFilename)
      newInst[1] = (double) data.attribute(1).addStringValue(subdirPath + File.separator + files[j]);
    newInst[data.classIndex()] = (double) k;
    data.add(new DenseInstance(1.0, newInst));
          is.close();
  }
  catch (Exception e) {
View Full Code Here

              // now check the other attributes against the training
              // structure
              boolean ok = true;
              for (int i = 0; i < testSet.numAttributes(); i++) {
                if (i != testSet.classIndex()) {
                  ok = testSet.attribute(i).equals(m_trainingSet.attribute(i));
                  if (!ok) {
                    break;
                  }
                }
              }
View Full Code Here

        for (int i=0; i<ignoredAtts.length; i++)
    selectedAtts[ignoredAtts[i]] = false;
    
      for (int i = 0; i < trainHeader.numAttributes(); i++) {
        if (selectedAtts[i]) {
    outBuff.append("              " + trainHeader.attribute(i).name()
             + '\n');
        }
      }
      if (ignoredAtts != null) {
        outBuff.append("Ignored:\n");
View Full Code Here

      }
      if (ignoredAtts != null) {
        outBuff.append("Ignored:\n");
        for (int i=0; i<ignoredAtts.length; i++)
    outBuff.append("              "
             + trainHeader.attribute(ignoredAtts[i]).name()
             + '\n');
      }
    } else {
      outBuff.append("              [list of attributes omitted]\n");
    }
View Full Code Here

        query.append(" ");
        query.append(m_createInt);
        query.append(" PRIMARY KEY,");
      }
      for(int i = 0;i < structure.numAttributes(); i++){
          Attribute att = structure.attribute(i);
          String attName = att.name();
          attName = attName.replaceAll("[^\\w]","_");
          attName = m_DataBaseConnection.maskKeyword(attName);
          if(m_DataBaseConnection.getUpperCase())
              query.append(attName.toUpperCase());
View Full Code Here

   
    m_DataBaseConnection.disconnectFromDatabase();
    //get rid of m_idColumn
    if(m_DataBaseConnection.getUpperCase())
        m_idColumn = m_idColumn.toUpperCase();
    if(result.attribute(0).name().equals(m_idColumn)){
        result.deleteAttributeAt(0);
    }
    m_structure = new Instances(result,0);
    }
    catch(Exception ex) {
View Full Code Here

      m_shapeSizes[index] = 10;
      m_previousShapeIndex = index;
     
      // Update the confusion matrix
//      double totalInstances =
      int tp = plotInstances.attribute(ThresholdCurve.TRUE_POS_NAME).index();
      int fp = plotInstances.attribute(ThresholdCurve.FALSE_POS_NAME).index();
      int tn = plotInstances.attribute(ThresholdCurve.TRUE_NEG_NAME).index();
      int fn = plotInstances.attribute(ThresholdCurve.FALSE_NEG_NAME).index();
      Instance temp = plotInstances.instance(index);
      double totalInstances = temp.value(tp) + temp.value(fp) + temp.value(tn) + temp.value(fn);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.