Let’s discuss a use case where we use SVM to classify new data as horses or mules.
Problem statement: Classify horses and mules using height and weight as the two features. Horses and mules typically have different weights and heights, with horses being heavier and taller.

The following are the steps to make the classification:

- Import the data set
- Make sure you have your libraries. The e1071 library has SVM algorithms built in. Create the support vectors using the library.
- Once the data is used to train the algorithm plot, the hyperplane gets a visual sense of how the data is separated. If the data is two-dimensional or three-dimensional, it will be easier to plot.
- Use the trained model to classify new values. We should have a training set and a test set. Then, ingest the new data. For our example, we’re going to use the whole dataset to train the algorithm and then see how it performs.
- Once you see how it performs, the algorithm will decide whether the image is a horse or a mule.
Here’s the R code:
