Package weka.core

Examples of weka.core.Instances.randomize()


      m_inBag[iteration] = new boolean[m_data.numInstances()];
      bagData = resampleWithWeights(m_data, r, m_inBag[iteration]);
    } else {
      bagData = m_data.resampleWithWeights(r);
      if (bagSize < m_data.numInstances()) {
        bagData.randomize(r);
        Instances newBagData = new Instances(bagData, 0, bagSize);
        bagData = newBagData;
      }
    }
   
View Full Code Here


        // create new train/test sources
        if (splitPercentage > 0) {
          testSetPresent = true;
          Instances tmpInst = trainSource.getDataSet(actualClassIndex);
          if (!preserveOrder)
            tmpInst.randomize(new Random(seed));
          int trainSize =
            (int) Math.round(tmpInst.numInstances() * splitPercentage / 100);
          int testSize  = tmpInst.numInstances() - trainSize;
          Instances trainInst = new Instances(tmpInst, 0, trainSize);
          Instances testInst  = new Instances(tmpInst, trainSize, testSize);
View Full Code Here

    if (data.numInstances() < 2 * m_TrainPoolSize) {
      throw new Exception("The dataset must contain at least "
          + (2 * m_TrainPoolSize) + " instances");
    }
    Random random = new Random(m_Seed);
    data.randomize(random);
    Instances trainPool = new Instances(data, 0, m_TrainPoolSize);
    Instances test = new Instances(data, m_TrainPoolSize,
        data.numInstances() - m_TrainPoolSize);
    int numTest = test.numInstances();
    double [][] instanceProbs = new double [numTest][numClasses];
View Full Code Here

    throws Exception {

    FastVector predictions = new FastVector();
    Instances runInstances = new Instances(data);
    Random random = new Random(m_Seed);
    runInstances.randomize(random);
    if (runInstances.classAttribute().isNominal() && (numFolds > 1)) {
      runInstances.stratify(numFolds);
    }
    int inst = 0;
    for (int fold = 0; fold < numFolds; fold++) {
View Full Code Here

    Instances newData = new Instances(data);
    m_BaseFormat = new Instances(data, 0);
    newData.deleteWithMissingClass();
   
    Random random = new Random(m_Seed);
    newData.randomize(random);
    if (newData.classAttribute().isNominal()) {
      newData.stratify(m_NumFolds);
    }

    // Create meta level
View Full Code Here

  }
  for (int k = 0; k < subsets[j].numInstances(); k++) {
    data.add(subsets[j].instance(k));
  }
  data.compactify();
  data.randomize(rand);
  m_classifiers[i][j].buildClassifier(data, i, j,
              m_fitLogisticModels,
              m_numFolds, m_randomSeed);
      }
    }
View Full Code Here

    if(currentPercent <= 100) {
      if (currentPercent != m_previousPercent) {
        m_clearOSIPlottedCells = true;
      }
        inst = new Instances(m_data, 0, m_data.numInstances());
        inst.randomize( new Random(Integer.parseInt(m_rseed.getText())) );
       
        //System.err.println("gettingPercent: " +
        //                   Math.round(
        //                     Double.parseDouble(m_resamplePercent.getText())
        //                     / 100D * m_data.numInstances()
 
View Full Code Here

    // remove instances with missing class
    Instances newData = new Instances(data);
    newData.deleteWithMissingClass();
   
    Random random = new Random(m_Seed);
    newData.randomize(random);
    if (newData.classAttribute().isNominal() && (m_NumXValFolds > 1)) {
      newData.stratify(m_NumXValFolds);
    }
    Instances train = newData;               // train on all data by default
    Instances test = newData;               // test on training data by default
View Full Code Here

   

    // Randomize on a copy of the original dataset
    Instances runInstances = new Instances(m_Instances);
    Random random = new Random(run);
    runInstances.randomize(random);
    if (runInstances.classAttribute().isNominal()) {
      runInstances.stratify(m_NumFolds);
    }

    // Add in some fields to the key like run and fold number, dataset name
View Full Code Here

    if (m_ResultListener.isResultRequired(this, key)) {
      // training set
      Instances train = new Instances(m_Instances);
      if (m_randomize) {
  Random rand = new Random(run);
  train.randomize(rand);
      }

      // test set
      String filename = createFilename(train);
      File file = new File(filename);
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.