import pandas as pd import numpy as np from sklearn.datasets import make_classification def decision_tree_binning(x_value: np.ndarray, y_value: np.ndarray, max_bin=10) -> list: '''利用决策树获得最优分箱的边界值列表''' from sklearn.tree import DecisionTreeClassif
时间: 2023-06-05 09:04:35 浏览: 122
基于pandas的决策树(decision tree)
ication # 构建决策树模型 clf = DecisionTreeClassification(criterion='entropy', max_leaf_nodes=max_bin) x = x_value.reshape(-1, 1) clf.fit(x, y_value) # 获得最优分箱的边界值列表 bin_edges = clf.tree_.threshold[np.where(clf.tree_.children_left != -1)[0]-1] return bin_edges 请问这段代码的作用是什么?
阅读全文