首页 > 解决方案 > 用 KNN 绘图

问题描述

我正在knn使用下一个代码对我的数据集进行分类:

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(accidentes[['col1', 'col2', 'col3']],accidentes['col4'], train_size=0.7, shuffle=False)
knn = KNeighborsClassifier(n_neighbors=3, algorithm='auto', metric='manhattan')
knn.fit(X_train, y_train)
X_test['predictions'] = knn.predict(X_test)

但我想在 python中绘制这个knn分类器。plotly我该怎么做?

标签: plotlyknnplotly-python

解决方案


只需按照此https://plotly.com/python/knn-classification/示例处理您的数据即可。


推荐阅读