IndexError

来源:3-5 神经网络对数据实现分类(下)

pythoner_

2017-10-28 20:42

ile "F:/python项目开发/神经网络/Neural+Networks.py", line 127, in plot_decision_regions
    plt.scatter(x=x[y==cl, 0], y = x[y==cl,1],alpha=0.8,c = cmap(idx),
IndexError: index 100 is out of bounds for axis 0 with size 100


求解答

写回答 关注

2回答

  • 慕村4605987
    2019-05-22 10:45:11

    y=df.loc和iloc不太一样

  • shaunjm
    2017-11-02 19:09:27

    y = df.loc[:100, 4].values 改为 y = df.loc[:99, 4].values

    或者

    x = df.iloc[:100, [0, 2]].values 改为 x = df.iloc[:101, [0, 2]].values

    不知道为啥,反正能运行了就,不然说数组越界

机器学习-实现简单神经网络

人工智能时代,你准备好成为抓住机遇的那百分之二吗。

67033 学习 · 184 问题

查看课程