2016-09-29 71 views
1

我試圖用frbs軟件包生成一個只包含一些默認參數的模型。我沒有得到任何錯誤,但結果是隻有一個值(最低值)的列。 當我爲不同的方法運行相同的代碼時,我得到了合理的結果。作爲模型結果的單值列

這種方法和我的代碼有什麼問題?

train <- iris[1 : 100, 1:4] 
test <- iris[101 : 150, 1 : 3] 
real <- matrix(iris[101 : 150, 4], ncol = 1) 
my_range=apply(iris[,1:4],2,range) 
method.type <- "ANFIS" 
control <- list(num.labels = 3, max.iter = 10, step.size = 0.01, type.tnorm = "MIN", type.snorm = "MAX", type.implication.func = "ZADEH", name = "diams") 
mod <- frbs.learn(train, my_range, method.type, control) 
prd<- predict(mod, test) 

回答

1

你需要有num.labels = 4(其中包括響應變量也):

control <- list(num.labels = 4, max.iter = 10, step.size = 0.01, type.tnorm = "MIN", type.snorm = "MAX", type.implication.func = "ZADEH", name = "diams") 
mod <- frbs.learn(train, my_range, method.type, control) 
prd<- predict(mod, newdata=test) 

head(prd) 
     [,1] 
[1,] 1.680819 
[2,] 1.422430 
[3,] 1.957765 
[4,] 1.693969 
[5,] 1.770748 
[6,] 2.262179 
+0

謝謝@sandipan它適用於這個例子,但我可以看到它適用於小列數。我有一個有22列和2312行的數據框,因此我仍然得到一個單一數字的列。 –

+1

可能需要更多的訓練示例/您可以嘗試更改參數,例如梯度下降的學習率或#max迭代。 –