Weka Percentage split 分割数据集

66%作为训练集,剩余的作为测试集
//读取
 Instances trainingSet = DataSource.read(path);
//打乱顺序		
		 trainingSet.randomize(new Random(0));
		int trainSize = (int) Math.round(trainingSet.numInstances() * 0.66);
		int testSize = trainingSet.numInstances() - trainSize;
		Instances train = new Instances(trainingSet, 0, trainSize);
		Instances test = new Instances(trainingSet, trainSize, testSize);

你可能感兴趣的:(split)