Package weka.core

Examples of weka.core.Instances.numClasses()


      }
     
      // Compute new list of non-empty classes and mapping of indices
      FastVector newClassVals = new FastVector(numNonEmptyClasses);
      int[] oldIndexToNewIndex = new int[newTrain.numClasses()];
      for (int i = 0; i < newTrain.numClasses(); i++) {
        if (notEmptyClass[i]) {
         oldIndexToNewIndex[i] = newClassVals.size();
          newClassVals.addElement(newTrain.classAttribute().value(i));
        }
      }
View Full Code Here


  System.err.println(x+": "+m_Class.value(x) + " has " +
         orderedClasses[x] + " instances.");
    }
    // Iterate from less prevalent class to more frequent one
  oneClass: 
    for(int y=0; y < data.numClasses()-1; y++){ // For each class       
     
      double classIndex = (double)y;
      if(m_Debug){
  int ci = (int)classIndex;
  System.err.println("\n\nClass "+m_Class.value(ci)+"("+ci+"): "
View Full Code Here

      data = rulesetForOneClass(expFPRate, data, classIndex, defDL);
    }

    // Set the default rule
    RipperRule defRule = new RipperRule();
    defRule.setConsequent((double)(data.numClasses()-1));
    m_Ruleset.addElement(defRule);
 
    RuleStats defRuleStat = new RuleStats();
    defRuleStat.setData(data);
    defRuleStat.setNumAllConds(m_Total);
View Full Code Here

    // Should empty bins be deleted?
    if (m_DeleteEmptyBins) {

      // Figure out which classes are empty after discretization
      int numNonEmptyClasses = 0;
      boolean[] notEmptyClass = new boolean[newTrain.numClasses()];
      for (int i = 0; i < newTrain.numInstances(); i++) {
        if (!notEmptyClass[(int)newTrain.instance(i).classValue()]) {
          numNonEmptyClasses++;
          notEmptyClass[(int)newTrain.instance(i).classValue()] = true;
        }
View Full Code Here

        }
      }
     
      // Compute new list of non-empty classes and mapping of indices
      FastVector newClassVals = new FastVector(numNonEmptyClasses);
      int[] oldIndexToNewIndex = new int[newTrain.numClasses()];
      for (int i = 0; i < newTrain.numClasses(); i++) {
        if (notEmptyClass[i]) {
         oldIndexToNewIndex[i] = newClassVals.size();
          newClassVals.addElement(newTrain.classAttribute().value(i));
        }
View Full Code Here

     * @return predicted class probability distribution
     * @throws Exception if there is a problem generating the prediction
     */
    public double[] distributionForInstance(BayesNet bayesNet, Instance instance) throws Exception {
        Instances instances = bayesNet.m_Instances;
        int nNumClasses = instances.numClasses();
        double[] fProbs = new double[nNumClasses];

        for (int iClass = 0; iClass < nNumClasses; iClass++) {
            fProbs[iClass] = 1.0;
        }
View Full Code Here

    
      m_offscreenPlotData = new ArrayList<Instances>();     
      Instances predictedI = e.getDataSet();
      if (predictedI.classIndex() >= 0 && predictedI.classAttribute().isNominal()) {
        // set up multiple series - one for each class
        Instances[] classes = new Instances[predictedI.numClasses()];
        for (int i = 0; i < predictedI.numClasses(); i++) {
          classes[i] = new Instances(predictedI, 0);
          classes[i].setRelationName(predictedI.classAttribute().value(i));
        }
        for (int i = 0; i < predictedI.numInstances(); i++) {
View Full Code Here

      m_offscreenPlotData = new ArrayList<Instances>();     
      Instances predictedI = e.getDataSet();
      if (predictedI.classIndex() >= 0 && predictedI.classAttribute().isNominal()) {
        // set up multiple series - one for each class
        Instances[] classes = new Instances[predictedI.numClasses()];
        for (int i = 0; i < predictedI.numClasses(); i++) {
          classes[i] = new Instances(predictedI, 0);
          classes[i].setRelationName(predictedI.classAttribute().value(i));
        }
        for (int i = 0; i < predictedI.numInstances(); i++) {
          Instance current = predictedI.instance(i);
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

      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

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.