Domanda

I'm trying to look what is possible with R and SVM's (e1071). But the results of the confusion matrix are to big to display.

For testing purpose I'm using Yahoo stock dataset from Yahoo Finance.
My R command set looks like this:

> library(e1071)
> yahooData <- read.csv(file="../StockData/yahoo/yahoo-full.csv")
> yahooData[1,]
        Date  Open  High   Low Close   Volume Adj.Close
1 2014-01-17 40.12 40.44 39.47 40.01 19262500     40.01
> dim(yahooData)
[1] 4473    7
> yIndex <- 1:nrow(yahooData)
> yTestindex <- sample(yIndex, trunc(length(yIndex)/3))
> yTestset <- yahooData[yTestindex,]
> yTrainset <- yahooData[-yTestindex,]
> dim(yTestset)
[1] 1491    7
> dim(yTrainset)
[1] 2982    7
> 
> # svm
> ySVMmodel <- svm(Close ~ ., data = yTrainset)
> ySVMpred <- predict(ySVMmodel, yTestset[,-5])

The summary of my SVM model and the prediction are:

> summary(ySVMmodel)

Call:
svm(formula = Close ~ ., data = yTrainset)


Parameters:
   SVM-Type:  eps-regression 
 SVM-Kernel:  radial 
       cost:  1 
      gamma:  0.000223314 
    epsilon:  0.1 


Number of Support Vectors:  493

> summary(ySVMpred)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  12.55   20.96   31.93   49.84   43.55  401.10 

At the end I want to get an confusion matrix to see my results, but the matrix is to big and I can't get any informations out of it:

> table(pred = ySVMpred, true = yTestset[,5])

Is there, beside of the confusion matrix, another approach to see the predicted values? Or another way to shrink the confusion matrix to get results?

È stato utile?

Soluzione

A confusion matrix is for assessing results from classification. You are actually using SVMs to perform regression. The appropriate approach would be to look at the residues (estimated minus actual) which can be studentized.

For this kind of data, the best approach to get a good feeling for the model fit, in my experience, is to plot the predicted time series versus the actual time series.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top