【用Python玩Machine Learning】KNN * 測試

樣本我就用的《machine learning in action》中提供的數據樣例,據說是婚戀網站上各個候選人的特徵,以及當前人對這些人的喜歡程度。一共1k條數據,前900條作爲訓練樣本,後100條作爲測試樣本。

數據格式如下:

46893	3.562976	0.445386	didntLike
8178	3.230482	1.331698	smallDoses
55783	3.612548	1.551911	didntLike
1148	0.000000	0.332365	smallDoses
10062	3.931299	0.487577	smallDoses
74124	14.752342	1.155160	didntLike
66603	10.261887	1.628085	didntLike
11893	2.787266	1.570402	smallDoses
50908	15.112319	1.324132	largeDoses
39891	5.184553	0.223382	largeDoses
65915	3.868359	0.128078	didntLike
65678	3.507965	0.028904	didntLike

最後的測試結果,100個測試樣本有11個樣本分類錯誤,錯誤率最終是11%。


補充一下,代碼+數據保存在github上面:https://github.com/henryxiao1997/machine-learning-in-python/tree/master/KNN


如有轉載,請註明出處:http://blog.csdn.net/xceman1997/article/details/44994327

發佈了167 篇原創文章 · 獲贊 65 · 訪問量 71萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章