unsup_df
is a DataFrame
which has only one column: review.
I want to form 2 clusters of the reviews. One positive and one negative.
from sklearn.cluster import KMeans
tfidf_vectorizer = TfidfVectorizer()
tfidf_matrix = tfidf_vectorizer.fit_transform(unsup_df)
num_clusters = 2
km = KMeans(n_clusters=num_clusters)
km.fit(tfidf_matrix)
clusters = km.labels_.tolist()
The above piece of code is throwing an error:
ValueError: n_samples=1 should be >= n_clusters=2
on the line km.fit(tfidf_matrix)