I am currently dealing with a time-series data set with cyclical gaps every 30 minutes (30 minutes of data, 30 minutes of no data). Is there a relatively simple way of using scikit-learn (or some other Python library) to predict the missing data using the available data to train it? I assume this would involve a 'supervised training' approach? I have provided a graph for visual reference, the orange line is a 20-minute centralized moving average of the gap data set, and I want to fill in the data to look more like the green 60-minute centralized moving average from a separate complete data set. Thanks!
You can approximate a time series with a polynomial of degree
n_degree by using
ridge regression. You can try different degree numbers (e.g.
[2,3,4,5,6]) and choose the best one. Keep in mind that higher degree models, always get lower error values. So you should somehow penalize higher degrees.
from sklearn.linear_model import Ridge from sklearn.preprocessing import PolynomialFeatures from sklearn.pipeline import make_pipeline for count, degree in enumerate([2, 3, 4, 5, 6]): model = make_pipeline(PolynomialFeatures(degree), Ridge()) model.fit(Time, y)
More details here.
What you are trying to do is called imputing (i.e. filling gaps) in the time-series.
A guide to imputing time-series using python is available here:
The guide uses a few algorithms to impute data, but a more extensive list of algorithms can be found here: