Skip to Content
Machine Learning in Java - Second Edition
book

Machine Learning in Java - Second Edition

by AshishSingh Bhatia, Bostjan Kaluza
November 2018
Intermediate to advanced
300 pages
7h 42m
English
Packt Publishing
Content preview from Machine Learning in Java - Second Edition

Evaluating models

Now, let's take a closer look at the evaluation function. The evaluation function accepts an initialized model, cross-validates the model on all three problems, and reports the results as an area under the ROC curve (AUC), as follows:

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++) { 

First, we call the Instance loadData(String, String) function that we implemented earlier to load the training data and merge it with the selected labels:

 // Load data Instances train_data = loadData( path + "orange_small_train.data", path+"orange_small_train_"+labelFiles[i]+".labels.txt"); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Java Machine Learning

Mastering Java Machine Learning

Uday Kamath, Krishna Choppella
Java: Data Science Made Easy

Java: Data Science Made Easy

Richard M. Reese, Jennifer L. Reese, Alexey Grigorev

Publisher Resources

ISBN: 9781788474399Supplemental Content