第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

這個(gè)要怎么解決?謝謝老師

NameError?????????????????????????????????Traceback?(most?recent?call?last)<ipython-input-15-aab8952af4eb>?in?<module>()---->?1?plot_decision_regions(X,?y,?classifier,?resolution=0.02)NameError:?name?'classifier'?is?not?defined
NameError?????????????????????????????????Traceback?(most?recent?call?last)<ipython-input-15-aab8952af4eb>?in?<module>()---->?1?plot_decision_regions(X,?y,?classifier,?resolution=0.02)NameError:?name?'classifier'?is?not?defined


正在回答

2 回答

你看一下代碼,照著改一下,應(yīng)該就能解決。
from?matplotlib.colors?import?ListedColormap
def?plot_decision_regions(X,?y,?classifier,?resolution=0.02):????
????marker?=?('s',?'x',?'o',?'v')????
????colors?=?('red',?'blue',?'lightgreen',?'gray',?'cyan')????
????cmap?=?ListedColormap(colors[:len(np.unique(y))])????
????x1_min,?x1_max?=?X[:,?0].min()?-?1,?X[:,?0].max()????
????x2_min,?x2_max?=?X[:,?1].min()?-?1,?X[:,?1].max()????
????#將x1、x2最大最小值通過(guò)arange函數(shù)得到的向量,擴(kuò)展成兩個(gè)二維矩陣????
????xx1,?xx2?=?np.meshgrid(np.arange(x1_min,?x1_max,?resolution),?np.arange(x2_min,?x2_max,?resolution))????
????#預(yù)測(cè)????
????Z?=?classifier.predict(np.array([xx1.ravel(),?xx2.ravel()]).T)?#ravel還原成單維向量????
????#繪制????
????Z=?Z.reshape(xx1.shape)?#將Z轉(zhuǎn)換成與xx1一樣的二維數(shù)組????
????plt.contourf(xx1,?xx2,?Z,?alpha=0.4,?cmap=cmap)?#在兩組分類結(jié)果中間畫分割線-->必須線性可分????
????plt.xlim(xx1.min(),?xx1.max())????
????plt.ylim(xx2.min(),?xx2.max())????
????for?idx,?cl?in?enumerate(np.unique(y)):????????
????????plt.scatter(x=X[y==cl,?0],?y=X[y==cl,?1],?alpha=0.8,?c=cmap(idx),?marker=marker[idx],?label=cl)
????????
????????
ppn?=?Perceptron(0.1,?10)
ppn.fit(X,?y)
plot_decision_regions(X,?y,?ppn,?resolution=0.02)


0 回復(fù) 有任何疑惑可以回復(fù)我~

classifier 應(yīng)該是個(gè)自定義的類,貌似視頻中沒(méi)有給出其實(shí)現(xiàn)。。。


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

這個(gè)要怎么解決?謝謝老師

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)