SVR with a linear model
We often have enough domain knowledge to take an approach that is more nuanced than simply minimizing prediction errors in our training data. Using this knowledge may allow us to accept more bias in our model, when small amounts of bias do not matter much substantively, to reduce variance. With SVR, we can adjust hyperparameters such as epsilon (the acceptable error range) and C (which adjusts the tolerance for errors outside of that range) to improve our model’s performance.
If a linear model can perform well on your data, linear SVR might be a good choice. We can build a linear SVR model with scikit-learn’s LinearSVR
class. Let’s try creating a linear SVR model with the gasoline tax data that we used in the previous chapter:
- We need many of the same libraries that we used in the previous chapter to create the training and testing DataFrames and to preprocess the data. We also need to import the
LinearSVR
anduniform
modules...