library(eegAnalysis)
###Simulating the data set.
Sim <- randEEG(n.class=2,n.rec=10,n.signals=50,n.channels = 2,
vars = c(2,1))
### Uncomment the next line to choose your own features
# features<-easyFeatures()
### Selecting the features
### The selected features may differ because the algorithm
### uses some random functions
### Obs: features="example" is used to be fast. Use features="default"
### or choose your own set of features.
x<-FeatureEEG(Sim$data,Sim$classes.Id,Sim$rec.Id,features="example",
Alpha=0.05, AlphaCorr=0.9,minacc=0.8,fast=FALSE)
### Calculating the classifier
y<-svmEEG(x)
y$model
### Generating new data to test the classifier
new <- randEEG(n.class=2,n.rec=30,n.signals=50,n.channels = 2,
vars = c(2,1))
### Classifying the new data and counting the number of successes
cont = 0
for(i in 1:30)
{
data<-new$data[which((new$classes.Id==1)&(new$rec.Id==i)),]
if(classifyEEG(y,data)[2]==1) cont = cont + 1
}
for(i in 1:30)
{
data<-new$data[which((new$classes.Id==2)&(new$rec.Id==i)),]
if(classifyEEG(y,data)[2]==2) cont = cont + 1
}
### The correct classification rate:
cont/60
Run the code above in your browser using DataLab