最贊回答 / Kaiz不是
因?yàn)閦=w0x0+w1x1+...+wmxm,從0到m一共是m+1列,X.shape[0]表示行數(shù),X.shape[1]表示列數(shù)X.shape[1]=mX.shape[1]+1 =m+1
2018-02-24
最新回答 / 慕的地591
<...code...>
已采納回答 / qq_Sunshine暖陽_0
5.1,3.5,1.4,0.2,Iris-setosa4.9,3.0,1.4,0.2,Iris-setosa4.7,3.2,1.3,0.2,Iris-setosa4.6,3.1,1.5,0.2,Iris-setosa5.0,3.6,1.4,0.2,Iris-setosa5.4,3.9,1.7,0.4,Iris-setosa4.6,3.4,1.4,0.3,Iris-setosa5.0,3.4,1.5,0.2,Iris-setosa4.4,2.9,1.4,0.2,Iris-setosa4.9,3.1,1.5,...
2018-01-09
最新回答 / 慕粉3647128
第一段改為如下寫法,具體原因可以對(duì)照得出:import numpy as npclass Perceptron(object):? ? """? ? eta:學(xué)習(xí)率? ? n_iter:權(quán)重向量的訓(xùn)練次數(shù)? ? w_:神經(jīng)分叉權(quán)重向量? ? errors_:用于記錄神經(jīng)元判斷出錯(cuò)次數(shù)? ? """? ? def __init__(self, eta = 0.01, n_iter=10):? ? ? ? self.eta = eta;? ? ? ? self.n_iter = n_iter;? ? ? ? ...
最新回答 / 嚴(yán)偉安
我也覺得不能解釋為出錯(cuò)的次數(shù),可以解釋為結(jié)果的準(zhǔn)確度(此處準(zhǔn)確度越小越好)
最新回答 / Mrbeargreat
cost_記錄的是J(w),意義是當(dāng)前預(yù)測(cè)結(jié)果和標(biāo)準(zhǔn)結(jié)果之間的和方差,最后繪圖的時(shí)候縱坐標(biāo)ylabel寫的也是和方差。
已采納回答 / 慕慕7251271
5.1,3.5,1.4,0.2,Iris-setosa4.9,3.0,1.4,0.2,Iris-setosa4.7,3.2,1.3,0.2,Iris-setosa4.6,3.1,1.5,0.2,Iris-setosa5.0,3.6,1.4,0.2,Iris-setosa5.4,3.9,1.7,0.4,Iris-setosa4.6,3.4,1.4,0.3,Iris-setosa5.0,3.4,1.5,0.2,Iris-setosa4.4,2.9,1.4,0.2,Iris-setosa4.9,3.1,1.5,...
最贊回答 / 慕的地591
我是這樣改的:import matplotlib.pyplot as pltimport numpy as npy = df.loc[0:99, 4].valuesy = np.where(y == 'Iris-setosa', -1, 1)#print(y)X = df.iloc[0:100, [0, 2]].values#print(X)plt.scatter(X[:50, 0], X[:50, 1], color='red', marker='o', label='setosa')plt.scatt...
最贊回答 / shaunjm
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不知道為啥,反正能運(yùn)行了就,不然說數(shù)組越界