Question
how would go about making the code below work? Provide code please. from sklearn.preprocessing import StandardScaler standard_scaler = StandardScaler() transformed_features_doc2vec = standard_scaler.fit_transform(features_doc2vec) model_kmeans = KMeans(n_clusters=k,
how would go about making the code below work? Provide code please.
from sklearn.preprocessing import StandardScaler standard_scaler = StandardScaler() transformed_features_doc2vec = standard_scaler.fit_transform(features_doc2vec) model_kmeans = KMeans(n_clusters=k, random_state=20130810) model_kmeans.fit(transformed_features_doc2vec) KMeans(n_clusters=4, random_state=20130810) labels_kmeans = model_kmeans.labels_ silhouette_score(transformed_features_doc2vec, labels_kmeans) for k in [4, 5, 6, 7, 8, 9]: model_kmeans = KMeans(n_clusters=k, random_state=20130810) model_kmeans.fit(transformed_features_doc2vec) sil_score = silhouette_score(transformed_features_doc2vec, model_kmeans.labels_) print(f"k = {k}, silhouette score = {sil_score}")#
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started