-
Notifications
You must be signed in to change notification settings - Fork 3
Predicting with the Model
dbraga edited this page Dec 14, 2014
·
3 revisions
A valid instance of a ModelTrainer.java class, Cloud.java and an instance of a Solr request are required for prediction purposes.
An example can be found in the PredictionDemo.java class
-
Create a model trainer instance and specify the URL of the Thoth Predictor. Initializing the class will also boot the H2o cloud and load the pre trained model
ModelTrainer modelTrainer = new ModelTrainer(); modelTrainer.setThothPredictorUri(THOTH_PREDICTOR_URL); modelTrainer.init(); modelTrainer.refresh();
-
Create an instance from a Solr request using the helper functions
String solrRequest = "q=*:*"
double[] instance = ArrayUtils.toPrimitive(
TruliaInstance.create(
TruliaConverter.solrQueryToQueryPojo(solrRequest, null, null, mapper)
, SLOW_QUERY_THRESHOLD, true)
);
- Use the Cloud class to fetch the prediction probabilities
float prediction = Cloud.predict(instance);
- Use the threshold connected to the current model to determine the prediction label
boolean isSlowQuery = (prediction < modelTrainer.getThreshold() )? false : true;
Step 1 : Sampling and Creation of the Dataset
Step 2 : Model Training
Step 3 : Exposing Trained Model via the API
Step 4 : Monitoring the Health of the Model
Step 5 : Predicting with the Model