0
$\begingroup$

I am new to SVM classifiers. I read on the internet that SVM are binary classifiers and also many SVMs, as described in research papers, only take 2 features as the input.

(e.g. https://scikit-learn.org/stable/auto_examples/svm/plot_iris.html)

My question is, does it have to be 2 input features? Can we use more than 2? If so, how do we write this code in python?

$\endgroup$

1 Answer 1

0
$\begingroup$

There is no restriction on the number of features.

The syntax is exactly the same. For your tutorial, rather than

X = iris.data[:, :2]

That takes only $2$ columns, just change it to a bigger number if those columsn area in your dataframe. It is a common practice that the last column is the $y$ values of which case just to remove that column, just use $-1$.

For some online tutorials, sometimes we use $2$ features for the convenience of visualization only.

However, note that we do not want to use too many features as we want to build a model can be generalized. A simple model that works is better than a complicated model.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.