zhaoxingfeng
zhaoxingfeng
只做了预剪枝,没有做后剪枝
你的考虑是对的,代码中的
The code is written by python2.7, for python3 replace by features = random.sample(df.columns.values[:-1].tolist(), int(math.sqrt(m - 1)))
《机器学习实战》k-近邻算法部分,P30 2.3.2
你好,看错误提示貌似你的pd.series索引为int类型,你在使用get_loc时可能给了string类型。当然只是猜测,如果要分析原因最好能贴代码,如果已经解决请忽略。 在 2018-05-09 13:39:22,"yangtzelsl" 写道: 请问这是哪里出错了呢? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the...
@yangtzelsl 找到原因了。你使用的是python3,在python3中range函数返回的是一个可迭代对象,而非python2中的list,所以会提示get_loc需要int类型。 改正:data, label = df[list(range(len(df.columns) - 1))], df[[len(df.columns) - 1]] 即可。