我正在通过“机器学习& Brett Lantz的R专家技术专家技术。我正在使用 tidymodels
套件在尝试R中的示例建模练习
。我已经使用下面显示的代码创建了模型,
c5_v1 <- C5_rules() %>%
set_mode('classification') %>%
set_engine('C5.0')
c5_res_1 <- fit(object = c5_v1, formula = default ~., data = credit_train)
这已经成功地工作了:
parsnip model object
Call:
C5.0.default(x = x, y = y, trials = trials, rules = TRUE, control
= C50::C5.0Control(minCases = minCases, seed = sample.int(10^5, 1), earlyStopping
= FALSE))
Rule-Based Model
Number of samples: 900
Number of predictors: 20
Number of Rules: 22
Non-standard options: attempt to group attributes
尽我所能,像我一样尝试Google,阅读 parsnips
文档等,i 无法找到出去如何查看决策树。谁能告诉我如何查看其创建的实际树?
I am working through 'Machine Learning & R Expert techniques for predictive modeling' by Brett Lantz. I am using the tidymodels
suite as I try the example modeling exercises in R.
I am working through chapter 5 in which you build a decision tree with the C5.0 algorithm. I hav e created the model using the code shown below
c5_v1 <- C5_rules() %>%
set_mode('classification') %>%
set_engine('C5.0')
c5_res_1 <- fit(object = c5_v1, formula = default ~., data = credit_train)
This has worked successfully:
parsnip model object
Call:
C5.0.default(x = x, y = y, trials = trials, rules = TRUE, control
= C50::C5.0Control(minCases = minCases, seed = sample.int(10^5, 1), earlyStopping
= FALSE))
Rule-Based Model
Number of samples: 900
Number of predictors: 20
Number of Rules: 22
Non-standard options: attempt to group attributes
Try as I might, Google as I do, read parsnips
documentation, etc., I cannot find out how to view the decision tree. Can anyone tell me how to view the actual tree it has created?
发布评论
评论(1)
请注意。因此,在使用
c5_rules()
是 rule-fit模型c5_rules()
拟合后,您不应该期望输出是决策树,而是一组规则。使用C5.0引擎,您可以同时获得决策树输出和规则输出。使用拟合模型,运行
extract_fit_engine()
以获取Parsnip模型拟合中嵌入的发动机特异性拟合,然后进行summary()
以提取输出。由
Do note
C5_rules()
is a specification for a rule-fit model. Therefore, after fitting withC5_rules()
, you shouldn't expect the output to be a decision tree but a set of rules instead.With the C5.0 engine, you're able to get both a decision tree output and a rules output. With the fitted model, run
extract_fit_engine()
to obtain the engine specific fit embedded within a parsnip model fit, followed bysummary()
to extract the output.Created on 2022-07-04 by the reprex package (v2.0.1)