0
我在R中使用包e1071來構建一個類的SVM模型。 我能夠對它進行建模並打印模型,但我無法繪製它。如何繪製R中的一類SVM?
我跟着這link,還有this,它使用虹膜數據集,但所有的SVM示例都使用C分類。
library(e1071)
day = c(0,1,2,3,4,5,6)
weather = c(6,5,4,3,2,1,0) #on the example, it was: c(1,0,0,0,0,0,0)
happy = factor(c(T,T,T,T,T,T,T)) #on the example it was: happy = factor(c(T,F,F,F,F,F,F))
d = data.frame(day=day, weather=weather, happy=happy)
model = svm(happy ~ day + weather, data = d, type='one-classification') #on the example it was: model = svm(happy ~ day + weather, data = d)
plot(model, d)
由於它是一個類我修改了相同的標籤的因素。它給出了以下錯誤:
Error in rect(0, levels[-length(levels)], 1, levels[-1L], col = col)
cannot mix zero-length and non-zero-length coordinates
In addition: Warning messages:
1: package 'e1071' was built under R version 3.2.3
2: In Ops.factor(yorig, ret$fitted) : '-' not meaningful for factors
我正在使用R版本3.2.2(2015-08-14)(窗口)。
如何繪製此模型?
謝謝
不是一個分類需要'nu'參數嗎? – sebastianmm
Hi @Sebastian M.Müller。是的,它的確如此,但是如果你不把它設爲默認值0.5 –
你是否試過'plot(model)'? – lejlot