pycaret.clustering.predict_model#

pycaret.clustering.predict_model(model, data: DataFrame) DataFrame[source]#

This function generates cluster labels using a trained model.

Example

>>> from pycaret.datasets import get_data
>>> jewellery = get_data('jewellery')
>>> from pycaret.clustering import *
>>> exp_name = setup(data = jewellery)
>>> kmeans = create_model('kmeans')
>>> kmeans_predictions = predict_model(model = kmeans, data = unseen_data)
model: scikit-learn compatible object

Trained Model Object.

datapandas.DataFrame

Shape (n_samples, n_features) where n_samples is the number of samples and n_features is the number of features.

Returns:

pandas.DataFrame

Warning

  • Models that do not support ‘predict’ method cannot be used in the predict_model.

  • The behavior of the predict_model is changed in version 2.1 without backward compatibility. As such, the pipelines trained using the version (<= 2.0), may not work for inference with version >= 2.1. You can either retrain your models with a newer version or downgrade the version for inference.