【问题标题】:Classifcation/Decision Trees and Choosing Splits分类/决策树和选择拆分
【发布时间】:2012-05-06 22:54:28
【问题描述】:

这是一个非常基本的例子。但我正在做一些数据分析,并且不断发现自己正在编写非常相似的 SQL 计数查询来生成概率表。

我的表被定义为值 0 表示事件没有发生,而值 1 表示事件确实发生了。

  > sqldf("select count(distinct Date) from joinedData where C_O_Above_prevHigh = 0 and  C_O_Below_prevLow = 0")
  count(distinct Date)
1                 1081

> sqldf("select count(distinct Date) from joinedData where C_O_Above_prevHigh = 0 and C_O_Below_prevLow = 0 and E_halfGap = 1")
  count(distinct Date)
1                  956

> sqldf("select count(distinct Date) from joinedData where C_O_Above_prevHigh = 1 OR C_O_Below_prevLow = 1 and E_halfGap = 1")
  count(distinct Date)
1                  504

在上面的示例中,我的预测变量是C_O_Above_prevHighC_O_Below_prevLow,我的结果变量是E_halfGap。在某些情况下,可能会有更多的预测变量,例如Time

R 或其他应用程序中是否有任何可用的东西:

1) 根据我的预测器输出潜在的概率路径? 2)允许我选择如何分割路径

感谢您的意见。

【问题讨论】:

    标签: r machine-learning data-mining classification decision-tree


    【解决方案1】:

    如果您想要所有总计和小计, 你可以在 SQL 中使用CUBE BY(但它不在 SQLite 中) 或addmargins 在 R 中。

    addmargins( Titanic )
    # More readable:
    ftable( addmargins( Titanic ) )
    

    如果你想构建一个决策树, 你可以使用rpart 包 或检查 machine learning 要么 graphical models 任务视图

    【讨论】:

    • 感谢您让我开始使用立方体。
    猜你喜欢
    • 2017-01-27
    • 2020-04-15
    • 2022-07-19
    • 2019-10-17
    • 2021-04-22
    • 2016-07-12
    • 2018-12-12
    • 2016-05-31
    • 2018-10-20
    相关资源
    最近更新 更多