-
大小: 30KB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-07
- 語言: Python
- 標簽: svm,python??
資源簡介
svm代碼,python實現(xiàn),包括數(shù)據(jù)集,實驗結果圖像等。參考字《機器學習實戰(zhàn)》
代碼片段和文件信息
from?svmMLiA?import?*
from?numpy?import?*
#?import?numpy?as?np
def?somSimple(dataMatIn?classLable?C?toler?maxIter):
????#?載入樣本和標簽,并初始化?alpha、iter
????dataMatrix?=?mat(dataMatIn)
????labelMatrix?=?mat(classLable).T
????b?=?0
????m?n?=?shape(dataMatrix)
????alphas?=?mat(zeros((m?1)))
????iter?=?0
????
????while(iter?????????alphaPairsChanged?=?0
????????for?i?in?range(m):
????????????fxi?=?float(multiply(alphas?labelMatrix).T?*?(dataMatrix?*?dataMatrix[i:].T))?+?b
????????????Ei?=?fxi?-?float(labelMatrix[i])
????????????if(((labelMatrix[i]?*?Ei?-toler)?and?(alphas[i]?????????????????((labelMatrix[i]?*?Ei?>?toler)?and?(alphas[i]?>?0))):
????????????????j?=?selectJrand(i?m)
????????????????fxj?=?float(multiply(alphas?labelMatrix).T?*?(dataMatrix?*?dataMatrix[
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????27429??2018-02-04?11:25??SVM\SmoSimple.png
?????文件???????3661??2018-02-04?11:24??SVM\SVM.py
?????文件???????2617??2018-02-04?11:23??SVM\svmMLiA.py
?????文件???????2208??2018-02-04?09:54??SVM\testSet.txt
?????文件???????2940??2018-02-04?11:23??SVM\__pycache__\svmMLiA.cpython-35.pyc
?????目錄??????????0??2018-02-04?11:23??SVM\__pycache__
?????目錄??????????0??2018-02-04?11:36??SVM
-----------?---------??----------?-----??----
????????????????38855????????????????????7
評論
共有 條評論