0
votes

I am working on a music data set where I have to classify the music data in to genres. I have both test and train data sets. I have linked the datasets for you to check here. I am working in Rstudio

Here's the code I have written. I am a beginner and have no clue what I am doing. I am shooting arrows randomly. Let me know if you need more information.

The library used is :-

library("e1071")

The code :-

svm.model <- svm(GENRE ~ ., data = musictraindata, cost = 62.5, gamma = 0.5)

Now my problem is what to put in x parameter. I have put "GENRE" from train data set but it's giving me the following error.

Error in svm.default(x, y, scale = scale, ..., na.action = na.action) : Need numeric dependent variable for regression.

Someone please guide me on what I should do. Thanks.

After corrections :- I ran the code with the said corrections.I got an svm.model as follows :-

svm.model

Call:
svm(formula = factor(GENRE) ~ ., data = musictraindata, cost = 62.5, gamma = 0.5, type = "C-classification", 
    tolerance = 0.01)

Parameters:
   SVM-Type:  C-classification 
 SVM-Kernel:  radial 
       cost:  62.5 
      gamma:  0.5 
Number of Support Vectors:  11880

Now I try to create a predict model by using it with test data.

svm.pred <- predict(svm.model,musictestdata)

When I plot the svm.pred, I get a graph as follows which is highly unlikely. Here it is:

plot(svm.pred)

This how I am suppose to proceed right ? Am I doing something wrong ? Let me know.

1

1 Answers

1
votes

Tough to say without a reproducible example, but I would confirm that the class of your dependent variable (Genre) is a factor, and doesn't have anything goofy going on like NA's. Check this with class(musictraindata$GENRE). Also worth a note, R is cap-sensitive so "Genre" and "GENRE" make a difference.

You can also try specficying the type of SVM you want to run by using (type = "C-classification") and see if it throws you a more helpful error?