Using SVM for Real‐Life Problems
We will end this chapter by applying SVM to a common problem in our daily lives. Consider the following dataset (saved in a file named
) containing the size of houses and their asking prices (in thousands) for a particular area:house_sizes_prices_svm.csv
size,price,sold
550,50,y
1000,100,y
1200,123,y
1500,350,n
3000,200,y
2500,300,y
750, 45,y
1500,280,n
780,400,n
1200, 450,n
2750, 500,n
The third column indicates if the house was sold. Using this dataset, you want to know if a house with a specific asking price would be able to sell.
First, let's plot out the points:
%matplotlib inline
import pandas as pd
import numpy as np
from sklearn import svm
import matplotlib.pyplot as plt
import seaborn as sns; sns.set(font_scale=1.2)
data = pd.read_csv('house_sizes_prices_svm.csv')
sns.lmplot('size', 'price',
data=data,
hue='sold',
palette='Set2',
fit_reg...