Support Vector Machines (SVMs) have gained popularity over the years. These very powerful models use kernel tricks to model even the most complicated relationships between the dependent and independent variables.
In this recipe, using artificially generated data, we will show the real power of SVMs.
To execute this recipe, you will need pandas
, NumPy
, Scikit
, and Matplotlib
. No other prerequisites are required.
In this recipe, we will test SVM for regression with four different kernels (the regression_svm.py
file):
import sys sys.path.append('..') # the rest of the imports import helper as hlp import pandas as pd import numpy as np import sklearn.svm as sv import matplotlib.pyplot as plt @hlp.timeit def regression_svm(x, y, **kw_params): ''' Estimate a SVM regressor ''' # create the regressor object svm = sv.SVR(**kw_params) # estimate the model svm.fit(x,y) # return...