Steve
Steve

Reputation: 4668

predicting closest cluster sklearn

I was reading this stackoverflow and had a further question. Once the clusters have been made, is it possible to determine what cluster a new sentence will fall into ?

Clustering text documents using scikit-learn kmeans in Python

Upvotes: 0

Views: 214

Answers (1)

Sergei Lebedev
Sergei Lebedev

Reputation: 2679

Sure, just use the predict method. Continuing the example from the referenced question

X_new = vectorizer.transform([sentence])
y_new = model.predict(X_new)

Upvotes: 1

Related Questions