Java Code Examples for weka.classifiers.Evaluation#crossValidateModel()

The following examples show how to use weka.classifiers.Evaluation#crossValidateModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformEnsembles.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
public void findCVWeights() throws Exception {
	cvWeights=new double[nosTransforms];
	int folds=numInstances;
	if(folds>THRESHOLD1){
			folds=10;
	}
	System.out.print("\n Finding CV Accuracy: ");
	for(int i=0;i<nosTransforms;i++){
		 Evaluation evaluation = new Evaluation(train.get(i));
                        if(i==0)
                           evaluation.crossValidateModel(AbstractClassifier.makeCopy(baseTime), train.get(i), folds, new Random());
                        else
                            evaluation.crossValidateModel(AbstractClassifier.makeCopy(base), train.get(i), folds, new Random());
		 cvWeights[i]=1-evaluation.errorRate();
		 System.out.print(","+cvWeights[i]);
	}
	 System.out.print("\n");
}
 
Example 2
Source File: KddCup.java    From Machine-Learning-in-Java with MIT License 5 votes vote down vote up
public static double[] evaluate(Classifier model) throws Exception {

		double results[] = new double[4];

		String[] labelFiles = new String[] { "churn", "appetency", "upselling" };

		double overallScore = 0.0;
		for (int i = 0; i < labelFiles.length; i++) {

			// Load data
			Instances train_data = loadData("data/orange_small_train.data",
											"data/orange_small_train_" + labelFiles[i]+ ".labels.txt");
			train_data = preProcessData(train_data);

			// cross-validate the data
			Evaluation eval = new Evaluation(train_data);
			eval.crossValidateModel(model, train_data, 5, new Random(1), new Object[] {});

			// Save results
			results[i] = eval.areaUnderROC(train_data.classAttribute()
					.indexOfValue("1"));
			overallScore += results[i];
			System.out.println(labelFiles[i] + "\t-->\t" +results[i]);
		}
		// Get average results over all three problems
		results[3] = overallScore / 3;
		return results;
	}
 
Example 3
Source File: TestUtil.java    From wekaDeeplearning4j with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Perform crossvalidation
 *
 * @param clf Classifier
 * @param data Full dataset
 */
public static void crossValidate(Classifier clf, Instances data) throws Exception {
  Evaluation ev = new Evaluation(data);
  ev.crossValidateModel(clf, data, 10, new Random(42));
  logger.info(ev.toSummaryString());
}
 
Example 4
Source File: TestUtil.java    From wekaDeeplearning4j with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Perform crossvalidation
 *
 * @param clf Classifier
 * @param data Full dataset
 */
public static void crossValidate(Classifier clf, Instances data) throws Exception {
  Evaluation ev = new Evaluation(data);
  ev.crossValidateModel(clf, data, 10, new Random(42));
  logger.info(ev.toSummaryString());
}