访问随机林模型中单个树的底层(树)对象(Python,scikit learn)
我需要将随机Fores模型转换为基于规则的模型或(如果是)基于规则的模型。我现在已经创建了我的模型,并且已经进行了很好的调整。我面临的问题是,我无法“访问”(base_estimator)或底层(tree_object),这将使创建一个可以从林中的树中提取规则的函数成为可能。如果你能在这个问题上帮助我,我将非常感激。要创建我使用的模型,请执行以下操作:访问随机林模型中单个树的底层(树)对象(Python,scikit learn),python,machine-learning,scikit-learn,random-forest,decision-tree,Python,Machine Learning,Scikit Learn,Random Forest,Decision Tree,我需要将随机Fores模型转换为基于规则的模型或(如果是)基于规则的模型。我现在已经创建了我的模型,并且已经进行了很好的调整。我面临的问题是,我无法“访问”(base_estimator)或底层(tree_object),这将使创建一个可以从林中的树中提取规则的函数成为可能。如果你能在这个问题上帮助我,我将非常感激。要创建我使用的模型,请执行以下操作: estimator = RandomForestRegressor(oob_score=True, n_estimators=10,ma
estimator = RandomForestRegressor(oob_score=True, n_estimators=10,max_features='auto')
我试着使用estimator.estimators\uuz
属性访问一棵树,然后使用例如estimator.estimators\u0].tree来获取用于构建森林的决策树(DecisionTreeRecessor
对象)。不幸的是,这种方法不起作用
如果可能的话,我想要如下内容:
estimator = RandomForestRegressor(oob_score=True, n_estimators=10,max_features='auto')
estimator.fit(tarning_data,traning_target)
tree1 = estimator.estimators_[0]
leftChild = tree1.tree_.children_left
rightChild = tree1.tree_.children_right
要访问随机林模型中的DecisionTreeRegressor
对象的底层结构,需要遵循以下步骤:
estimator = RandomForestRegressor(oob_score=True,n_estimators=10,max_features='auto')
estimator.fit(tarning_data,traning_target)
tree1 = estimator.estimators_[0]
leftChilds = tree1.tree_.children_left # array of left children
rightChilds = tree1.tree_.children_right #array of right children
i、 e.问题中已经描述的基本内容