Package weka.core

Examples of weka.core.Instances.randomize()


    train.compactify();
    test.compactify();
   
    // randomize the final sets
    train.randomize(rand);
    test.randomize(rand);
  } else {
   
    // Numeric target
    int trainSize =
      Utils.probRound(runInstances.numInstances() * m_TrainPercent / 100, rand);
View Full Code Here


        break;

        case 1: // CV mode
        m_Log.statusMessage("Randomizing instances...");
        Random random = new Random(seed);
        inst.randomize(random);
        if (inst.attribute(classIndex).isNominal()) {
    m_Log.statusMessage("Stratifying instances...");
    inst.stratify(numFolds);
        }
        for (int fold = 0; fold < numFolds;fold++) {
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

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

      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() && (m_Instances.numInstances() / m_StepSize >= 1)) {
//      runInstances.stratify(m_Instances.numInstances() / m_StepSize);
    }*/

 
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

    public void run() {
      boolean errorOccurred = false;
      try {
        Random random = new Random(getSeed());
        if (!m_preserveOrder) {
          dataSet.randomize(random);
        }
        if (dataSet.classIndex() >= 0 &&
      dataSet.attribute(dataSet.classIndex()).isNominal() &&
      !m_preserveOrder) {
    dataSet.stratify(getFolds());
View Full Code Here

        Random rnrR = new Random(42);

        try {
            Instances allInst = new Instances(new BufferedReader(new FileReader(fileName)));
            allInst.setClassIndex(allInst.numAttributes() - 1);
            allInst.randomize(rnrR);
           
            // Creates the two new Sets
//            Resample stratResampleSmall = new Resample();
//            stratResampleSmall.setBiasToUniformClass(0);
//            stratResampleSmall.setInvertSelection(false);
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.