Package weka.core

Examples of weka.core.Instances.randomize()


  inBag[j] = new boolean[data.numInstances()];
  bagData = resampleWithWeights(data, random, inBag[j]);
      } else {
  bagData = data.resampleWithWeights(random);
  if (bagSize < data.numInstances()) {
    bagData.randomize(random);
    Instances newBagData = new Instances(bagData, 0, bagSize);
    bagData = newBagData;
  }
      }
     
View Full Code Here


    if (m_splitThread == null) {
      final Instances dataSet = new Instances(e.getDataSet());
      m_splitThread = new Thread() {
    public void run() {
      try {
        dataSet.randomize(new Random(m_randomSeed));
        int trainSize =
                (int)Math.round(dataSet.numInstances() * m_trainPercentage / 100);
        int testSize = dataSet.numInstances() - trainSize;
     
        Instances train = new Instances(dataSet, 0, trainSize);
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

      throw new Exception("No Instances set");
    }
    // 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);
    }
    for (int fold = 0; fold < m_NumFolds; fold++) {
      // Add in some fields to the key like run and fold number, dataset name
View Full Code Here

    Instances[] testData = new Instances[m_numFolds];
    LFSMethods[] searchResults = new LFSMethods[m_numFolds];

    Random random = new Random(m_seed);
    Instances dataCopy = new Instances(data);
    dataCopy.randomize(random);

    if (dataCopy.classAttribute().isNominal()) {
      dataCopy.stratify(m_numFolds);
    }
View Full Code Here

    }
    m_InitOptions = ((OptionHandler)m_Classifier).getOptions();
    m_BestPerformance = -99;
    m_NumAttributes = trainData.numAttributes();
    Random random = new Random(m_Seed);
    trainData.randomize(random);
    m_TrainFoldSize = trainData.trainCV(m_NumFolds, 0).numInstances();

    // Check whether there are any parameters to optimize
    if (m_CVParams.size() == 0) {
       m_Classifier.buildClassifier(trainData);
View Full Code Here

      throw new Exception("No Instances set");
    }

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

    // Tell the resultproducer to send results to us
View Full Code Here

        Vector segmentList = new Vector(q + 1);
       
        //Set random seed
        Random random = new Random(m_Seed);
       
        data.randomize(random);
       
        //create index arrays for different segments
       
        int currentDataIndex = 0;
View Full Code Here

                                }
                            }
                        }
                    }
                   
                    TP.randomize(random);
                   
                    if( getTrainSize() > TP.numInstances() ){
                        throw new Exception("The training set size of " + getTrainSize() + ", is greater than the training pool "
                        + TP.numInstances() );
                    }
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 = 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

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.