Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

Linear Regression after k-means clustering

Goodmorning everyone, I'm stuck on a ml code, that's asking to apply linear regression on the clusters obtained on a certain dataset (including vectors of features). After datas pre-processing I proceeded with the following for clustering:

from sklearn import metrics
from sklearn.cluster import KMeans

kmeans = KMeans(n_clusters=5, n_init=10, random_state=numero_di_matricola)
kmeans.fit(Xtrain_and_val_scaled)

Since it was required 5 clusters. Now I have to apply linear regression to each one of these and then compute the error (1 - R^2) on the data not used to learn the models (or better, the test set). I can't find any help around, any suggestion?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...