Notebook
scikit-learn-pythonmldata-sciencemachinelearningmicrosoft-for-beginnersworking3-SVRmachine-learningmachinelearning-pythoneducationmicrosoft-ML-For-Beginnersscikit-learnPythonmachine-learning-algorithms7-TimeSeriesr
Export
Time series prediction using Support Vector Regressor
In this notebook, we demonstrate how to:
- prepare 2D time series data for training an SVM regressor model
- implement SVR using RBF kernel
- evaluate the model using plots and MAPE
Importing modules
[1]
[2]
Preparing data
Load data
[3]
Plot the data
[ ]
Create training and testing data
[ ]
[ ]
Preparing data for training
Now, you need to prepare the data for training by performing filtering and scaling of your data.
[ ]
Scale the data to be in the range (0, 1).
[ ]
[ ]
Creating data with time-steps
For our SVR, we transform the input data to be of the form [batch, timesteps]. So, we reshape the existing train_data and test_data such that there is a new dimension which refers to the timesteps. For our example, we take timesteps = 5. So, the inputs to the model are the data for the first 4 timesteps, and the output will be the data for the 5th timestep.
[ ]
[ ]
[ ]
[ ]
[ ]
Creating SVR model
[ ]
[ ]
Make model prediction
[ ]
Analyzing model performance
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
Full dataset prediction
[ ]
[ ]
[ ]
[ ]