Skip to content

predict


method predict(X, verbose=None)[source]
Get class predictions on new data or rows in the dataset.

New data is first transformed through the model's pipeline. Transformers that are only applied on the training set are skipped. The estimator must have a predict method.

Read more in the user guide.

ParametersX: int, str, slice, sequence or dataframe-like
Names or indices of rows in the dataset, or new feature set with shape=(n_samples, n_features).

verbose: int or None, default=None
Verbosity level of the output. If None, it uses the transformer's own verbosity.

Returnsseries or dataframe
Class predictions with shape=(n_samples,) or shape=(n_samples, n_targets) for multioutput tasks.

Example

>>> from atom import ATOMClassifier
>>> from sklearn.datasets import load_breast_cancer

>>> # Load data and separate last 5 rows for predictions
>>> X, y = load_breast_cancer(return_X_y=True, as_frame=True)
>>> X_new, y_new = X.iloc[-5:], y.iloc[-5:]
>>> X, y = X.iloc[:-5], y.iloc[:-5]

>>> atom = ATOMClassifier(data)
>>> atom.run("LR")

>>> # Using new data
>>> atom.predict(X_new)

0    0
1    0
2    0
3    0
4    1
Name: predict, dtype: int32

>>> # Using indices
>>> atom.predict([23, 25])  # Retrieve prediction of rows 23 and 25

23    1
25    1
dtype: int32