【用Python玩Machine Learning】KNN * 测试

来源:互联网 发布:gentoo linux 乱码 编辑:程序博客网 时间:2024/06/09 14:50

样本我就用的《machine learning in action》中提供的数据样例,据说是婚恋网站上各个候选人的特征,以及当前人对这些人的喜欢程度。一共1k条数据,前900条作为训练样本,后100条作为测试样本。

数据格式如下:

468933.5629760.445386didntLike81783.2304821.331698smallDoses557833.6125481.551911didntLike11480.0000000.332365smallDoses100623.9312990.487577smallDoses7412414.7523421.155160didntLike6660310.2618871.628085didntLike118932.7872661.570402smallDoses5090815.1123191.324132largeDoses398915.1845530.223382largeDoses659153.8683590.128078didntLike656783.5079650.028904didntLike

最后的测试结果,100个测试样本有11个样本分类错误,错误率最终是11%。


补充一下,代码+数据保存在github上面:https://github.com/henryxiao1997/machine-learning-in-python/tree/master/KNN


如有转载,请注明出处:http://blog.csdn.net/xceman1997/article/details/44994327

0 0