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
258 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 Answer

0 votes
by (71.8m points)
Waitting for answers

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

...