Concept | Scoring data

See the video version of this article


After a model has been successfully deployed to the Flow, it is ready to be used to predict new, unseen data. In our case, we trained a model on historical patient data and are now ready to predict whether new patients will be readmitted to the hospital.

We’ll use the Score recipe to apply our model to this new, unseen data.

  • The inputs to the Score recipe are a deployed model and a dataset of new, unlabelled records that we want to score.

  • The output is a scored dataset showing predictions for each record.

../../_images/score-recipe-concept.png

Preparing unlabelled data

However, before using the Score recipe, you’ll usually need to carefully prepare the dataset to be scored. In this case our model was trained on a very specific set of features. If we want the model to perform as we expect on new data, we need to provide the model the exact same set of features, with the same names, prepared in the same manner.

../../_images/unlabelled-data-concept.png

In Dataiku, this means that the data to be scored must pass through the same Flow recipes used to create any features found in the training set. For example, this Prepare recipe did some processing on the Age feature when creating the training set.

../../_images/scoring-flow-prepare.png

Sending the new data through these same steps is the best way to ensure that the model behaves similarly on new patients as it did during the model training and evaluation phase with the historic data. One efficient way to do this in Dataiku is to use a Stack recipe to combine your training and unlabelled datasets.

From that point, we can build features using Flow recipes and finally use a Split recipe to split back the patient data into historical data for training and new, unlabelled patients to be scored.

../../_images/scoring-stack-split.png

Doing this ensures that features are identical for model training and inference.

The Score recipe

Once the unlabelled dataset is ready to be scored by the deployed model, a Score recipe can be created in the Flow.

The Score recipe takes two inputs: a deployed model and a dataset ready to be scored. It outputs a dataset containing the model predictions.

../../_images/score-dialog.png

Note that if in the Flow we first select the dataset to be scored instead of the saved model, we’ll find a Predict recipe that allows us to apply a previously created prediction model. This is just a difference of terminology. The following dialog and operation is exactly the same.

../../_images/scoring-predict.png

In addition to model predictions, the Score recipe lets you output additional information like individual predictions explanations using ICE or Shapley values. This way, in addition to predicting the probability that a patient will be readmitted to the hospital, we can also provide the features contributing to the prediction to take further action.

../../_images/score-explanations.png

Once the recipe is finished running, it outputs the original dataset along with additional columns containing the model prediction, prediction details, and individual explanations if requested. The number and information provided by these columns will differ based on the prediction type.

../../_images/scored-flow.png

Here, our model is performing a binary classification. As a result, the scoring recipe outputs the probabilities for the positive and negative classes and the final prediction based on the optimal classification threshold found during the training phase.

../../_images/scored-data-output.png

In some cases, we’ll look at the probability of the positive class rather than the binary prediction. For example, we might want to rank patients per probability of being readmitted to take care of those that are the most likely to be readmitted.

What’s next?

Learn how to manage different versions of a model and keep iterating and improving it in :doc: concept-model-validation-evaluation.