2013-12-20 77 views
0

我正在經歷這個svm tutorial並試圖將其應用於我的數據。在R中創建svm的數據集(e1071)

我讀我的SQLite中的數據矩陣EPT

不過,對我來說,結構類似於

> print (cats) 
    Sex Bwt Hwt 
1  F 2.0 7.0 
2  F 2.0 7.4 
... 
48 M 2.0 6.5 
49 M 2.0 6.5 

> print(ept) 
     EPT  DIL   BRT  EX 
1  T640 -0.968750 -0.372549020 0.32400 
2  T640 -0.968750 -0.325490196 0.32400 
... 
30 T1280 -0.984375 0.082352941 -0.04675 
31 T1280 -0.984375 0.145098039 -0.04675 
... 

貓總結在第一列中產生不同的輸出結構:

> summary(cats) 
Sex   Bwt    Hwt  
F:47 Min. :2.000 Min. : 6.30 
M:97 1st Qu.:2.300 1st Qu.: 8.95 
     Median :2.700 Median :10.10 
     Mean :2.724 Mean :10.63 
     3rd Qu.:3.025 3rd Qu.:12.12 
     Max. :3.900 Max. :20.50 
> summary(ept) 
    EPT     DIL    BRT     EX   
Length:119   Min. :-0.9844 Min. :-0.71765 Min. :-0.5587 
Class :character 1st Qu.:-0.9688 1st Qu.:-0.42353 1st Qu.:-0.0235 
Mode :character Median :-0.9375 Median :-0.16078 Median : 0.1555 
        Mean :-0.8887 Mean :-0.16981 Mean : 0.1635 
        3rd Qu.:-0.8750 3rd Qu.: 0.04706 3rd Qu.: 0.5000 
        Max. : 0.0000 Max. : 0.59216 Max. : 0.5000 

然後調用EPT數據也失敗:

> data(cats) 
> data(ept) 
Warning: 
In data(ept) : data-set ‘ept’ not found # my translation here 
> 

我在這裏錯過了什麼?我怎樣才能爲svm(e1071)創建自己的數據集?

回答

0

好的,我已經發現了。 似乎像定義類的列應該是類型因子。

幫助轉換被:

ept$EPT <- factor(ept$EPT)