課程
/后端開發(fā)
/Python
/機器學習-實現(xiàn)簡單神經(jīng)網(wǎng)絡
最后結果下面多了一條線?請問這種情況是怎么回事呀
2019-03-30
源自:機器學習-實現(xiàn)簡單神經(jīng)網(wǎng)絡 3-5
正在回答
from matplotlib.colors import ListedColormap
from?matplotlib.colors?import?ListedColormap def?plot_decision_region(X,?y,?classifier,?resolution=0.02): ????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() ????xx1,?xx2?=?np.meshgrid(np.arange(x1_min,?x1_max,?resolution),?np.arange(x2_min,?x2_max,?resolution)) ????z?=?classifier.predict(np.array([xx1.ravel(),xx2.ravel()]).T) ????z?=?z.reshape(xx1.shape) ????plt.contourf(xx1,?xx2,?z,?alpha=0.4,?cmap=cmap) ????plt.xlim(xx1.min(),?xx1.max()) ????plt.xlim(xx2.min(),?xx2.max()) ????plt.scatter(X[:50,0],X[:50,1],color='red',marker='o',label='setosa')????????? ????plt.scatter(X[50:100,0],X[50:100,1],color='blue',marker='x',label='versicolor') #?執(zhí)行語句 plot_decision_regions(X,y,ppn,resolution=0.02) plt.rcParams['font.sans-serif']?=?['SimHei'] plt.xlabel('花莖長度') plt.ylabel('花瓣長度') plt.legend(loc='upper?left') plt.show()
#?plt.plot(range(1,len(ppn.errors_)+1),ppn.errors_,marker='o') #?plt.xlabel('Epochs') #?plt.ylabel('錯誤分類次數(shù)') #plt.show()
這些代碼注釋掉
舉報
人工智能時代,你準備好成為抓住機遇的那百分之二嗎。
2 回答最后的效果圖中,畫出cost_的效果圖,不能解釋為隨著迭代次數(shù)的增加,出現(xiàn)錯誤的次數(shù)變少了。
1 回答我的圖像繪制不對勁,求老師和大佬幫忙
1 回答運行了沒有任何結果
2 回答激活函數(shù)計算的結果
2 回答為什么最小值要減一呢
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2020-07-20
from matplotlib.colors import ListedColormap
2019-08-20
這些代碼注釋掉