Skip to main content

Model.predict

Model.predict(targets, source, explanation=False, confidence=False, probabilities=False, limit=None)

Predict the specified targets given the input dataset with the model this method is
called upon. The dataset must have all the columns that the model was trained on. The
targets also must be the same targets that the model was trained to predict.

Parameters:

   targets: Union[str, List[str]]
Target column or list of target columns to predict on.

   source: Union[Dataset, pd.DataFrame, str]
Dataset, dataframe, or name of dataset to run inference on.

   explanation: bool, default False
Whether to produce feature importances along with each prediction.

   confidence: bool, default False
Whether to produce confidence levels along with each prediction.

   probabilities: Union[bool, List[str]], default False
Whether to produce class probabilities of all classes, or a specific list of classes along with each prediction.

   limit: int, default None
The number of predictions to return.

   engine: Engine, default None*
The engine to use for executing the predict. Uses the user's default engine if not set.

Returns:

   pd.DataFrame

Examples:

Predict binary target Survived on a test dataset and include model confidence levels.

    df = pd.read_csv('titanic_test.csv')

model = pc.get_model('Titanic Model')

df = model.predict('Survived', df, confidence=True)
df.head()