Home > other >  Scikit - learn the decision tree of return, how to acquire the mse value node?
Scikit - learn the decision tree of return, how to acquire the mse value node?

Time:09-26

Generated by decision tree in the regression model, use graphviz to see the tree structure, there is an mse value, I need to get each leaf node of the mse value, according to the value for subsequent to the size of the operation, but the along while didn't find a way to provide the output document, the value of the other names like characteristics, sample number, value and so on has provided the corresponding method,


With the help (tree) sklearn. Tree. _tree. can see most of the attributes provides a method, but didn't see about the mse,

CodePudding user response:

Use tree_reg. Tree_. Impurity,

 
Tree_reg=tree. DecisionTreeRegressor (max_depth=2)
Tree_reg. Fit (X_train y_train)

Extracted_MSEs=tree_reg. Tree_. Impurity # for MSE values

For independence idx, MSE in enumerate (tree_reg. Tree_. Impurity) :
Print (" Node from the MSE {} {} ". The format (independence idx, MSE))

Node 0 from the MSE 86.873403833
The Node from the MSE 40.3211827171 1
The Node from the MSE 25.6934820064 2
The Node 3 from the MSE 19.0053469592
The Node 4 from the MSE 74.6839429717
The Node 5 from the MSE 38.3057346817
Node 6 from the MSE 39.6709615385

Since a wave, or learning is not solid, of impurity on the decision tree does not reach the designated position,

CodePudding user response:

Want to ask next, the mse and the value in this figure is how to calculate
  • Related