Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

How do I plot / visualize a KNN classifier model I've made in sklearn and using pandas dataframe

from sklearn.neighbors import KNeighborsClassifier
knn =KNeighborsClassifier(n_neighbors=5)
X = trainfile[['WS48M','WS100M','WS152M',]] #Features         
y = (trainfile['wind_Energy_Kwh'])#Target variable
knn.fit(X_train, y_train)
print("Response for test dataset:")
y_pred = knn.predict(X_test)
print(y_pred)

X=X.values
y=y.values
# Plotting decision region
plot_decision_regions(X, y, clf=trainfile, legend=2)
# Adding axes annotations
plt.xlabel('wind_Energy_Kwh')
plt.ylabel('Windspeed')
plt.title('Knn with K='+ str(k))
plt.show()
question from:https://stackoverflow.com/questions/65944303/how-do-i-plot-visualize-a-knn-classifier-model-ive-made-in-sklearn-and-using

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...