Original Source Here
Python Implementation (Real-World Dataset)
Let’s implement SVM on a real-world dataset as well. We will be using the
digits dataset. It is an image dataset containing images of digits in grayscale. We will be flattening the images so that the pixels can be used as features.
We will start by importing the required libraries, loading the dataset and plotting some of the images:
The images will be quite blurry as the dimensions are quite low
We will now start by flattening the images, splitting our dataset into train and test, initializing our model, fitting our model to the training data, and finally making predictions on the dataset.
Let’s now plot some of our test data, along with the predictions and the actual label.
The predictions look quite identical. But let’s calculate the score and plot the confusion matrix to get the bigger picture:
This gives us an accuracy of around 94% which is quite good as we didn’t tweak any hyperparameters.
Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot