Get a Single Prediction

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

Syntax

Use the predict() method to make a single prediction by passing the specific values as its argument:

/**
 * Make prediction with the model
 * 
 * @param data         Input data
 * @return prediction  Result in Tablesaw Table
 */
 public tech.tablesaw.api.Table predict(Map<String, String> data);

Example

Model llama3 = mindsdb.getModelWithVersion("llama3", 1);
Table response = llama3.predict(Map.of("question", "what do you know about mindsdb?")); 
System.out.println(response);
Project mindsdb = server.getProject();
Model homeRentalsModel = mindsdb.getModel("home_rentals_model");

Table prediction = homeRentalsModel.predict(Map.of(
                    "sqft", "1500",
                    "location", "good",
                    "neighborhood", "downtown",
                    "days_on_market", "10"
                    ));
System.out.println(prediction);
Updated on