Get Batch Predictions

The predict() function fetches predictions from the model table.

Syntax

Use the predict() method to make batch predictions by passing the data table as its argument:

 Model homeRentalsModel = mindsdb.getModel("home_rentals_model");
 Query query = mindsdb.query("SELECT * FROM example_db.home_rentals limit 5;");
 Table prediction = homeRentalsModel.predict(query.fetch());
 System.out.println(prediction.selectColumns("rental_price", "rental_price_original"));

Output

Or you can pass MDBTable object to the predict function for prediction

Project mindsdb = server.getProject();
Database exampleDb = server.getDatabase("example_db");
MDBTable homeRentalTable = exampleDb.getTable("home_rentals");
Model homeRentalPredictor = mindsdb.getModel("home_rentals_model");
Table rentPrediction = homeRentalPredictor.predict(homeRentalTable.limit(3));

Or you create a Tablesaw Table and pass it to make predictions.

Updated on