Nonlinear SVM classification models
Although nonlinear SVC is more complicated conceptually than linear SVC, as we saw in the first section of this chapter, running a nonlinear model with scikit-learn is relatively straightforward. The main difference from a linear model is that we need to do a fair bit more hyperparameter tuning. We have to specify values for C
, for gamma
, and for the kernel we want to use.
While there are theoretical reasons for hypothesizing that some hyperparameter values might work better than others for a given modeling challenge, we usually resolve those values empirically, that is, with hyperparameter tuning. We try that in this section with the same NBA games data that we used in the previous section:
- We load the same libraries that we used in the previous section. We also import the
LogisticRegression
module. We will use that with a feature selection wrapper method later:import pandas as pd import numpy as np from sklearn.preprocessing import MinMaxScaler...