KMeans.fit_predict

KMeans.fit_predict(data)

Fits the estimator using the provided data and subsequently predicts the labels for the data using the fitted estimator. It simply chains calls to fit() and predict().

Parameters

data (TypeVar(D_contra, contravariant=True)) -- The data to use for fitting and to predict labels for. The data must have the same type as for the fit() method.

Return type

TypeVar(R_co, covariant=True)

Returns

The predicted labels. Consult the predict() documentation for more information on the return type.