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


  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_NumAntds != -1){
      grow(data);
    }
    else{

      data.randomize(m_Random);

      // Split data into Grow and Prune    
      data.stratify(m_Folds);
 
      Instances growData=data.trainCV(m_Folds, m_Folds-1, m_Random);
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

      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

  RidorRule rule = new RidorRule();                               
  rule.setPredictedClass(0);       // Predict the classes other than default
   
  for(int j = 0; j < m_Shuffle; j++){
    if(m_Shuffle > 1)
      data.randomize(m_Random);
       
    rule.buildClassifier(data);
       
    double wr, w; // Worth rate and worth
    if(m_IsAllErr){
View Full Code Here

    // weights for root nodes of each fold for prepruning and postpruning.
    int expansion = 0;

    Random random = new Random(m_Seed);
    Instances cvData = new Instances(data);
    cvData.randomize(random);
    cvData = new Instances(cvData,0,(int)(cvData.numInstances()*m_SizePer)-1);
    cvData.stratify(m_numFoldsPruning);

    Instances[] train = new Instances[m_numFoldsPruning];
    Instances[] test = new Instances[m_numFoldsPruning];
View Full Code Here

        break;

        case 2: // Percent split
        m_Log.statusMessage(Messages.getInstance().getString("ClustererPanel_StartClusterer_Run_Log_StatusMessage_Fourth"));
        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

        break;

        case 1: // CV mode
        m_Log.statusMessage(Messages.getInstance().getString("AttributeSelectionPanel_StartAttributeSelection_Run_Log_StatusMessage_Text_Second"));
        Random random = new Random(seed);
        inst.randomize(random);
        if (inst.attribute(classIndex).isNominal()) {
    m_Log.statusMessage(Messages.getInstance().getString("AttributeSelectionPanel_StartAttributeSelection_Run_Log_StatusMessage_Text_Third"));
    inst.stratify(numFolds);
        }
        for (int fold = 0; fold < numFolds;fold++) {
View Full Code Here

     
      m_Antds = new FastVector()
     
      /* Split data into Grow and Prune*/
      m_Random = new Random(m_Seed);
      data.randomize(m_Random);
      data.stratify(m_Folds);
      Instances growData=data.trainCV(m_Folds, m_Folds-1, m_Random);
      Instances pruneData=data.testCV(m_Folds, m_Folds-1);
     
      grow(growData);      // Build this rule
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.