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:
This how I am suppose to proceed right ? Am I doing something wrong ? Let me know.