Reputation: 11
I have two data set like below 1st dataset
x1 x2 types
1 3 1
2 4 1
3 5 1
2nd dataset
x1 x2 types
4 8 -1
2 10 -1
3 12 -1
in 1st dataset x2 = 2+x1
amd 2nd x2= 2*x1
how can I train the dataset for SVM in R language
so that if i input another data like(2,4) it will present in class 2
Upvotes: 1
Views: 206
Reputation: 557
You have to tell svm() which is the class that has the label that describes you data, what is your dataset, and what parameters you want to use.
For example, supposing all of your data is together on a dataframe called "dataset" you could call:
svm(types ~., data = dataset, kernel = "radial", gamma = 0.1, cost = 1)
To check what parameters are better for your problem you can use tune.svm().
tune.svm(types~., data = dataset, gamma = 10^(-6:-1), cost = 10^(-3:1))
Upvotes: 1