Package weka.core

Examples of weka.core.Instances.numClasses()


      Instances toFilter = getInputFormat();
      Instances[] toFilterIgnoringAttributes;

      // Make subsets if class is nominal
      if ((toFilter.classIndex() >= 0) && toFilter.classAttribute().isNominal()) {
  toFilterIgnoringAttributes = new Instances[toFilter.numClasses()];
  for (int i = 0; i < toFilter.numClasses(); i++) {
    toFilterIgnoringAttributes[i] = new Instances(toFilter, toFilter.numInstances());
  }
  for (int i = 0; i < toFilter.numInstances(); i++) {
    toFilterIgnoringAttributes[(int)toFilter.instance(i).classValue()].add(toFilter.instance(i));
View Full Code Here


      Instances[] toFilterIgnoringAttributes;

      // Make subsets if class is nominal
      if ((toFilter.classIndex() >= 0) && toFilter.classAttribute().isNominal()) {
  toFilterIgnoringAttributes = new Instances[toFilter.numClasses()];
  for (int i = 0; i < toFilter.numClasses(); i++) {
    toFilterIgnoringAttributes[i] = new Instances(toFilter, toFilter.numInstances());
  }
  for (int i = 0; i < toFilter.numInstances(); i++) {
    toFilterIgnoringAttributes[(int)toFilter.instance(i).classValue()].add(toFilter.instance(i));
  }
View Full Code Here

    toFilterIgnoringAttributes[i] = new Instances(toFilter, toFilter.numInstances());
  }
  for (int i = 0; i < toFilter.numInstances(); i++) {
    toFilterIgnoringAttributes[(int)toFilter.instance(i).classValue()].add(toFilter.instance(i));
  }
  m_priors = new double[toFilter.numClasses()];
  for (int i = 0; i < toFilter.numClasses(); i++) {
    toFilterIgnoringAttributes[i].compactify();
    m_priors[i] = toFilterIgnoringAttributes[i].sumOfWeights();
  }
  Utils.normalize(m_priors);
View Full Code Here

  }
  for (int i = 0; i < toFilter.numInstances(); i++) {
    toFilterIgnoringAttributes[(int)toFilter.instance(i).classValue()].add(toFilter.instance(i));
  }
  m_priors = new double[toFilter.numClasses()];
  for (int i = 0; i < toFilter.numClasses(); i++) {
    toFilterIgnoringAttributes[i].compactify();
    m_priors[i] = toFilterIgnoringAttributes[i].sumOfWeights();
  }
  Utils.normalize(m_priors);
      } else {
View Full Code Here

      // build the clusterers
      if ((toFilter.classIndex() <= 0) || !toFilter.classAttribute().isNominal()) {
  m_clusterers = AbstractDensityBasedClusterer.makeCopies(m_clusterer, 1);
  m_clusterers[0].buildClusterer(toFilterIgnoringAttributes[0]);
      } else {
  m_clusterers = AbstractDensityBasedClusterer.makeCopies(m_clusterer, toFilter.numClasses());
  for (int i = 0; i < m_clusterers.length; i++) {
    if (toFilterIgnoringAttributes[i].numInstances() == 0) {
      m_clusterers[i] = null;
    } else {
      m_clusterers[i].buildClusterer(toFilterIgnoringAttributes[i]);
View Full Code Here

  }
      }
    }

    // Compute initial class counts
    double[] classProbs = new double[train.numClasses()];
    for (int i = 0; i < train.numInstances(); i++) {
      Instance inst = train.instance(i);
      classProbs[(int)inst.classValue()] += inst.weight();
    }
View Full Code Here

    props.add("Filename: " + panel.getFilename());
    props.add("Relation name: " + inst.relationName());
    props.add("# of instances: " + inst.numInstances());
    props.add("# of attributes: " + inst.numAttributes());
    props.add("Class attribute: " + inst.classAttribute().name());
    props.add("# of class labels: " + inst.numClasses());
   
    dialog = new ListSelectorDialog(getParentFrame(), new JList(props));
    dialog.showDialog();
  }
 
View Full Code Here

        }

        if (data.classAttribute().type() != Attribute.NOMINAL) {
            throw new Exception("Class attribute must be nominal");
        }
        int numClasses = data.numClasses();

        data.deleteWithMissingClass();
        if ( data.checkForStringAttributes() ) {
            throw new Exception("Can't handle string attributes!");
        }
View Full Code Here

    m_currentInstance = valSet.instance(nob);
    if (!m_currentInstance.classIsMissing()) {
      //this is where the network updating occurs, for the validation set
      resetNetwork();
      calculateOutputs();
      right += (calculateErrors() / valSet.numClasses())
        * m_currentInstance.weight();
      //note 'right' could be calculated here just using
      //the calculate output values. This would be faster.
      //be less modular
    }
View Full Code Here

      data.setClassIndex(m_ClassIndex);
    }
    if (data.classAttribute().type() != Attribute.NOMINAL) {
      throw new Exception("Class attribute must be nominal");
    }
    int numClasses = data.numClasses();

    data.deleteWithMissingClass();
    if (data.checkForStringAttributes()) {
      throw new Exception("Can't handle string attributes!");
    }
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.