【问题标题】:How can I build a decision-tree classification model with multiple categorical variables?如何构建具有多个分类变量的决策树分类模型?
【发布时间】:2021-12-02 10:16:21
【问题描述】:

我是一个完全的菜鸟,所以这是一个相当基本的问题。我希望在 SAS 中构建基于决策树的分类模型。

我无法在我的问题中嵌入图片,也无法附加图片,但我有一个正在使用的数据集。

这是我的数据集的链接预览: 我正在尝试使用 SAS 中的 hpsplit 过程构建此决策树,但它不起作用。我想是因为:

(1) 我没有使用所有的分类变量

(2) 我在“node-caps”列中缺少值:可用选项为 yesno? - 我想我应该使用“ASSIGNMISSING”程序,但不确定。见图片:

这是我当前的代码:

proc hpsplit data=bcancer seed=1;
class class;
model class = Age Menopause tumor_size inv_nodes node_caps deg_malig breast breast_quad irradiat;
grow entropy;
prune costcomplexity;
run;

我认为我应该是:

(1) 在第二行添加更多变量(因为它们是分类的)

(2) 添加“ASSIGNMISSING”过程以解决一列中缺失的变量。见链接:https://i.imgur.com/aJmB3kx.png

NOTE: The ASSIGNMISSING= option has not been specified.  Because of this, all observations with
      missing values in the explanatory variables will be excluded from tree construction.
ERROR: Character variable appeared on the MODEL statement without appearing on a CLASS statement.
ERROR: Unable to create a usable predictor variable set.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE HPSPLIT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

作为参考,这是我在日志中看到的错误。任何帮助将不胜感激!

【问题讨论】:

    标签: sas decision-tree categorical-data


    【解决方案1】:

    分类变量需要在 CLASS 语句中。看起来您的许多变量都是分类变量,需要在 CLASS 语句中。 连续变量应该是数字,但我在您的数据中看不到任何变量。

    因为分类变量 node_caps 是字符 ? 将被分配为一个级别,而不是作为缺失。您是否希望它们被编码为缺失或包含在该变量自己的级别中?

    proc hpsplit data=bcancer seed=1;
    class age menopause tutor_size inv_nodes node_caps deg_malig breast breast_quad irradiat;
    model class = Age Menopause tumor_size inv_nodes node_caps deg_malig breast breast_quad irradiat;
    grow entropy;
    prune costcomplexity;
    run;
    

    【讨论】:

      猜你喜欢
      • 2021-04-22
      • 2016-09-11
      • 2015-01-11
      • 2017-01-27
      • 2017-11-09
      • 2021-03-15
      • 2016-07-29
      • 2014-08-23
      • 2018-05-03
      相关资源
      最近更新 更多