2015-06-23 31 views
-1

我有一些個人數據集。所以我把它分成變量來預測和預測。 以下是語法:在R中使用Cubist包時,爲什麼會出現下面的錯誤?

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 

有什麼我失蹤?

回答

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造成具有單一的結果可能性的無信息的錯誤消息。

+0

我其實有很多列在我的數據幀。所以可能是這一列本身就是造成這個問題的原因。另外,當我使用包括可能單個值的列在內的所有列時,仍然會出現錯誤 - 對於其他軟件包(如rpart等)不會發生此錯誤。我將再次測試並添加:)。然而,在我的數據集中,有許多層次的許多分類變量是立體派的問題嗎? –

+0

你說得對,我只是刪除了單層的列和它的工作正常。但是這種行爲預計不正確? –

+0

如果軟件包中出現「嘿,當只有一個結果時我如何預測結果?」會更好。 - 建議您聯繫維護人員並提出建議。 – Spacedman

相關問題