Package weka.core

Examples of weka.core.Instance.numAttributes()


      }
      outW = new PrintWriter(getWriter());
      // print data file
      for (int i = 0; i < instances.numInstances(); i++) {
  Instance temp = instances.instance(i);
        for(int j = 0; j < temp.numAttributes(); j++){
            if(j != instances.classIndex()){
                if (temp.isMissing(j)) {
          outW.write("?,");
        } else if (instances.attribute(j).isNominal() ||
             instances.attribute(j).isString()) {
View Full Code Here


   * the pivot.
   */
  public static Instance calcPivot(BallNode child1, BallNode child2,
                                         Instances inststhrows Exception {
    Instance p1 = child1.getPivot(), p2 = child2.getPivot();
    double[] attrVals = new double[p1.numAttributes()];
   
    for(int j=0; j<attrVals.length; j++) {
      attrVals[j] += p1.value(j);
      attrVals[j] += p2.value(j);
      attrVals[j] /= 2D;
View Full Code Here

  double x = convertFromPanelX(mouseX);
  double y = convertFromPanelY(mouseY);
 
  //build the training instance
  Instance newInstance = new DenseInstance(m_trainingData.numAttributes());
  for (int i = 0; i < newInstance.numAttributes(); i++) {
    if (i == classAttIndex) {
      newInstance.setValue(i,classValue);
    }
    else if (i == m_xAttribute)
      newInstance.setValue(i,x);
View Full Code Here

   * the pivot.
   */
  public static Instance calcPivot(BallNode child1, BallNode child2,
                                         Instances inststhrows Exception {
    Instance p1 = child1.getPivot(), p2 = child2.getPivot();
    double[] attrVals = new double[p1.numAttributes()];
   
    for(int j=0; j<attrVals.length; j++) {
      attrVals[j] += p1.value(j);
      attrVals[j] += p2.value(j);
      attrVals[j] /= 2D;
View Full Code Here

      }
      outW = new PrintWriter(getWriter());
      // print data file
      for (int i = 0; i < instances.numInstances(); i++) {
  Instance temp = instances.instance(i);
        for(int j = 0; j < temp.numAttributes(); j++){
            if(j != instances.classIndex()){
                if (temp.isMissing(j)) {
          outW.write("?,");
        } else if (instances.attribute(j).isNominal() ||
             instances.attribute(j).isString()) {
View Full Code Here

         
          if (current.value(actualClass) != current.value(actualClass - 1)) {
            Instance toAdd = (Instance)current.copy();
           
            // larger shape for an error
            toAdd.setValue(toAdd.numAttributes() - 1, 5);
           
            // swap predicted and actual class value so
            // that the color plotted for the error series
            // is that of the predicted class
            double actualClassV = toAdd.value(actualClass);
View Full Code Here

    }
    else {
      outInst = inst;
    }
   
    for (i = 0; i < outInst.numAttributes(); i++) {
      if (i > 0)
  result.append(m_FieldSeparator);
     
      if (outInst.isMissing(i))
  field = m_MissingValue;
View Full Code Here

   
    if (m_encodeMissingAsZero && !m_insertDummyNominalFirstValue) {
      Instance tempInst = (Instance)instance.copy();
      tempInst.setDataset(getInputFormat());
     
      for (int i = 0; i < tempInst.numAttributes(); i++) {
        if (tempInst.isMissing(i)) {
          tempInst.setValue(i, 0);
        }
      }
      instance = tempInst;
View Full Code Here

  vInd = (int)instance.classValue();
      }

      // Iterate through all relevant string attributes of the current instance
      Hashtable h = new Hashtable();
      for (int j = 0; j < instance.numAttributes(); j++) {
  if (m_SelectedRange.isInRange(j) && (instance.isMissing(j) == false)) {

    // Get tokenizer
    m_Tokenizer.tokenize(instance.stringValue(j));
View Full Code Here

    if (isOutputFormatDefined()) {
      Instance newInstance = (Instance)instance.copy();
     
      // make sure that we get the right indexes set for the converted
      // string attributes when operating on a second batch of instances
      for (int i = 0; i < newInstance.numAttributes(); i++) {
        if (newInstance.attribute(i).isString() &&
            !newInstance.isMissing(i) &&
            m_AttIndices.isInRange(i)) {
          Attribute outAtt =
            getOutputFormat().attribute(newInstance.attribute(i).name());
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.