📄 gettree
字号:
getTree package:randomForest R Documentation
_E_x_t_r_a_c_t _a _s_i_n_g_l_e _t_r_e_e _f_r_o_m _a _f_o_r_e_s_t.
_D_e_s_c_r_i_p_t_i_o_n:
This function extract the structure of a tree from a
'randomForest' object.
_U_s_a_g_e:
getTree(rfobj, k=1, labelVar=FALSE)
_A_r_g_u_m_e_n_t_s:
rfobj: a 'randomForest' object.
k: which tree to extract?
labelVar: Should better labels be used for splitting variables and
predicted class?
_D_e_t_a_i_l_s:
For numerical predictors, data with values of the variable less
than the splitting point go to the left daughter node.
For categorical predictors, the splitting point is represented by
an integer, whose binary expansion gives the identities of the
categories that goes to left or right. For example, if a
predictor has three categories, and the split point is 5. The
binary expansion of 5 is (1, 0, 1) (because 5 = 1*2^0 + 0*2^1 +
1*2^2), so cases with categories 1 or 3 in this predictor get sent
to the left, and the rest to the right.
_V_a_l_u_e:
A matrix (or data frame, if 'labelVar=TRUE') with six columns and
number of rows equal to total number of nodes in the tree. The
six columns are:
left daughter: the row where the left daughter node is; 0 if the node
is terminal
right daughter: the row where the right daughter node is; 0 if the node
is terminal
split var: which variable was used to split the node; 0 if the node is
terminal
split point: where the best split is; see Details for categorical
predictor
status: is the node terminal (-1) or not (1)
prediction: the prediction for the node; 0 if the node is not terminal
_A_u_t_h_o_r(_s):
Andy Liaw andy_liaw@merck.com
_S_e_e _A_l_s_o:
'randomForest'
_E_x_a_m_p_l_e_s:
data(iris)
## Look at the third trees in the forest.
getTree(randomForest(iris[,-5], iris[,5], ntree=10), 3, labelVar=TRUE)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -