Questions tagged «decision-tree»


5
将分类数据传递到Sklearn决策树
关于如何将分类数据编码到Sklearn决策树中,有几篇文章,但是从Sklearn文档中,我们得到了这些 决策树的一些优点是: (...) 能够处理数字和分类数据。其他技术通常专用于分析仅具有一种类型的变量的数据集。有关更多信息,请参见算法。 但是运行以下脚本 import pandas as pd from sklearn.tree import DecisionTreeClassifier data = pd.DataFrame() data['A'] = ['a','a','b','a'] data['B'] = ['b','b','a','b'] data['C'] = [0, 0, 1, 0] data['Class'] = ['n','n','y','n'] tree = DecisionTreeClassifier() tree.fit(data[['A','B','C']], data['Class']) 输出以下错误: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/site-packages/sklearn/tree/tree.py", …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.