use*_*396 5 python entropy decision-tree binning scikit-learn
假设我有一个数据集:
X y
20 0
22 0
24 1
27 0
30 1
40 1
20 0
...
Run Code Online (Sandbox Code Playgroud)
我尝试通过最小化熵将 X 离散化为几个容器。所以我做了以下事情:
clf = tree.DecisionTreeClassifier(criterion = 'entropy',max_depth = 4)
clf.fit(X.values.reshape(-1,1),y.values)
threshold = clf.tree_.threshold[clf.tree_.threshold>-2]
threshold = np.sort(threshold)
Run Code Online (Sandbox Code Playgroud)
“阈值”应该给出分割点,这是数据分箱的正确方法吗?
有什么建议么?
首先,你的做法是正确的。
有多种方法可以对数据进行分类:
| 归档时间: |
|
| 查看次数: |
3196 次 |
| 最近记录: |