Package weka.core

Examples of weka.core.Instances.randomize()


        // 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


        break;

        case 2: // Percent split
        m_Log.statusMessage("Randomizing instances...");
        inst.randomize(new Random(1));
        trainInst.randomize(new Random(1));
        int trainSize = trainInst.numInstances() * percent / 100;
        int testSize = trainInst.numInstances() - trainSize;
        Instances train = new Instances(trainInst, 0, trainSize);
        Instances test = new Instances(trainInst, trainSize, testSize);
        Instances testVis = new Instances(inst, trainSize, testSize);
View Full Code Here

    filter.setInputFormat(instances);
    instances = Filter.useFilter(instances, filter);
   
   
    Random ran = new Random(System.currentTimeMillis());
    instances.randomize(ran);
   
    int max = 20;
    double[] acc = new double[max];
    while(max > 0) {
     
View Full Code Here

    double[] acc = new double[max];
    while(max > 0) {
     
      //copy and randomize instances
      Instances full = new Instances(instances);
      full.randomize(ran);
     
      // using 5 fold CV to emulate the 80-20 random split of jkms
      Instances train = full.trainCV(5, 0);
      Instances test = full.testCV(5, 0);
     
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 (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

    }
    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

      // theInstances.stratify(10);
       
      CVincreased = false;
      cvr = new Random(getSeed());
      trainCopy = new Instances(m_theInstances);
      trainCopy.randomize(cvr);
      templl = 0.0;
      for (i = 0; i < numFolds; i++) {
  Instances cvTrain = trainCopy.trainCV(numFolds, i, cvr);
  if (num_clusters > cvTrain.numInstances()) {
    break CLUSTER_SEARCH;
View Full Code Here

            newInstance.setClassValue( instance.classValue( ) );
            dataSubSet.add( newInstance );
          }
        }

        dataSubSet.randomize(random);
        // Remove a percentage of the instances
  Instances originalDataSubSet = dataSubSet;
  dataSubSet.randomize(random);
        RemovePercentage rp = new RemovePercentage();
        rp.setPercentage( m_RemovedPercentage );
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

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.