此博客為博主原創(chuàng)文章,轉(zhuǎn)載請(qǐng)注明出處。謝謝
本章內(nèi)容:
1、Sigmoid函數(shù)和Losgistic回歸分類(lèi)器
2、最優(yōu)化理論初步
3、梯度下降最優(yōu)化算法
4、數(shù)據(jù)中的缺失項(xiàng)處理
在運(yùn)行<程序清單5-4 改進(jìn)的隨機(jī)梯度上升算法>出現(xiàn)出現(xiàn)錯(cuò)誤:
In [38]:reload(logRegres)
Out[38]: <module 'logRegres' from 'D:\\py\\meachinelearning\\ch05\\logRegres.py'>
In [39]:dataArr, labelMat = logRegres.loadDataSet()
In [40]:weights = logRegres.stocGradAscent1(array(dataArr), labelMat)
Traceback (most recent call last):
……
del (dataIndex[randIndex])
TypeError: 'range' object doesn't support item deletion
#經(jīng)過(guò)看出錯(cuò)信息發(fā)現(xiàn)是del (dataIndex[randIndex])出現(xiàn)錯(cuò)誤。
將dataIndex = range(m)更改為dataIndex = list(range(m)),解決問(wèn)題。
關(guān)于處理數(shù)據(jù)中的缺失值可以看《利用Python進(jìn)行數(shù)據(jù)分析》這本書(shū)。
出現(xiàn)問(wèn)題,搜索出現(xiàn)比較好的參考:
預(yù)測(cè)數(shù)值型數(shù)據(jù)——回歸
《機(jī)器學(xué)習(xí)實(shí)戰(zhàn)》筆記之八——預(yù)測(cè)數(shù)值型數(shù)據(jù):回歸
機(jī)器學(xué)習(xí)-Logistic回歸python實(shí)現(xiàn)
機(jī)器學(xué)習(xí)4logistic回歸