Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

书中的一个IndexError #9

Open
zy19970 opened this issue Jul 15, 2020 · 2 comments
Open

书中的一个IndexError #9

zy19970 opened this issue Jul 15, 2020 · 2 comments

Comments

@zy19970
Copy link

zy19970 commented Jul 15, 2020

def getshow():
    # Positive sample
    all_x = X[:, 0]
    all_y = X[:, 1]
    # Negative sample
    all_negative_x = [1, 0]
    all_negative_y = [1, 1]
    # Calculate the slope and intercept of the dividing line
    k = -W[2] / W[3]
    b = -(W[0] + W[1]) / W[3]
    xdata = np.linspace(0, 5)
    plt.figure()
    plt.plot(xdata, xdata * k + b, 'r')
    plt.plot(all_x, all_y, 'bo')
    plt.plot(all_negative_x, all_negative_y, 'yo')
    plt.show()

在书中第15页。其中不存在W[2]和W[3],所以k和b无法求解

@longpeng2008
Copy link
Owner

有的噢,数据的维度就是4维的,W也是4维的,你把数据带进去就可以得到直线的公式了

1 similar comment
@longpeng2008
Copy link
Owner

有的噢,数据的维度就是4维的,W也是4维的,你把数据带进去就可以得到直线的公式了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants