小编Unk*_*own的帖子

正在获取TypeError:'(slice(None,None,None),0)'是无效的密钥

试图绘制k-NN分类器的决策边界,但无法这样做,但得到TypeError:'(slice(None,None,None),0)'是无效键`

    h = .01  # step size in the mesh

    # Create color maps
    cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA', '#AAAAFF','#AFAFAF'])
    cmap_bold  = ListedColormap(['#FF0000', '#00FF00', '#0000FF','#AFAFAF'])

    for weights in ['uniform', 'distance']:
        # we create an instance of Neighbours Classifier and fit the data.
        clf = KNeighborsClassifier(n_neighbors=6, weights=weights)
        clf.fit(X_train, y_train)

        # Plot the decision boundary. For that, we will assign a color to each
        # point in the mesh [x_min, x_max]x[y_min, y_max].
        x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1 …
Run Code Online (Sandbox Code Playgroud)

python machine-learning knn

8
推荐指数
6
解决办法
1万
查看次数

标签 统计

knn ×1

machine-learning ×1

python ×1