【问题标题】:Why do I get this error below while using the Cubist package in R?为什么在 R 中使用 Cubist 包时会出现以下错误?
【发布时间】:2023-03-27 11:03:01
【问题描述】:

我有一些个人数据集。所以我把它分成变量来预测和预测。 以下是语法:

library(Cubist)
str(A)
'data.frame':   6038 obs. of  3 variables:
 $ ads_return_count : num  7 10 10 4 10 10 10 10 10 9 ...
 $ actual_cpc       : num  0.0678 0.3888 0.2947 0.0179 0.095 ...
 $ is_user_agent_bot: Factor w/ 1 level "False": 1 1 1 1 1 1 1 1 1 1 ...
cubist(A[,c("ads_return_count","is_user_agent_bot")],A[,"actual_cpc"])

我收到以下错误

cubist code called exit with value 1
Error in strsplit(tmp, "\"")[[1]] : subscript out of bounds

我有什么遗漏吗?

【问题讨论】:

    标签: r regression decision-tree non-linear-regression


    【解决方案1】:

    模拟一些数据来做一个可重现的例子:

    A=data.frame(ads_return_count=sample(100,10,TRUE), actual_cpc=runif(100), is_user_agent_bot=factor(rep("False",100)))
    
    cubist(A[,c("ads_return_count","is_user_agent_bot")],A[,"actual_cpc"])
    cubist code called exit with value 1
    Error in strsplit(tmp, "\"")[[1]] : subscript out of bounds
    

    太好了,现在我们在同一个页面上。

    困扰我的是第二个论点,即结果,全是“假”。我不确定只有一个结果的模型是否有意义。让我们尝试一下有两种结果:

    > A2=data.frame(ads_return_count=sample(100,10,TRUE), actual_cpc=runif(100), is_user_agent_bot=sample(c("True","False"),100,TRUE))
    > cubist(A2[,c("ads_return_count","is_user_agent_bot")],A2[,"actual_cpc"])
    
    Call:
    cubist.default(x = A2[, c("ads_return_count", "is_user_agent_bot")], y =
     A2[, "actual_cpc"])
    
    Number of samples: 100 
    Number of predictors: 2 
    
    Number of committees: 1 
    Number of rules: 1 
    

    我会说这是来自cubist 的无信息错误消息,由单一结果可能性引起。

    【讨论】:

    • 我的数据框中实际上有很多列。所以可能是这个专栏本身导致了这个问题。此外,当我使用所有列(包括可能的单值列)时,我仍然会收到错误 - 这不会发生在其他包(如 rpart 等)中。然后我将再次测试并添加:)。然而,在我的数据集中,有很多级别的分类变量是立体派的问题吗?
    • 你是对的,我只是删除了单层的列并且它工作正常。但这种行为不是预期的吗?
    • 如果包裹是“嘿,当只有一个结果时,我如何预测结果?”会更好。 - 建议你联系维护者并提出建议。
    【解决方案2】:

    我的问题与我的相同,但结果是关卡名称缺少值“”。用文本替换这些级别就可以了。

    似乎c5.0决策树也有类似的问题 C5.0 decision tree - c50 code called exit with value 1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-13
      • 1970-01-01
      • 2021-06-26
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多