Approximating a time series — time series and it’s analysis.
By: Venali Sonone
Tags: Machine Learning, Time Series Analysis, Data Science, Artificial Intelligence, Time Series Forecasting

Let’s take baby steps before jumping into our four algorithms of discussions and their implementations.

Let’s talk on approximates.

We already started that “Approximation algorithms try to capture the most important information from time series. They can be seen as simple feature extraction algorithms.”

For me, time series is simply “data which reflects additional information of relevance of time in its structure.”

To give a logical explanation a time series is a series of data having:

1. Start

2. End &

3. Frequency of the data points itself.

Given this structure of time series, we can say there is x-value representing data and a y-value representing time-stamp and ts as series {(x, y)} in the Cartesian coordinate system.

There could certainly be instances where the x-value is missing due to whatsoever reason. We could sit a missing value is a value having a y-value in time-series i.e it has timestamp but no data or x-value associated with it. In the previous article, we filled in ‘ffill’ etc

A research paper states:

“A missing value consists of the timestamp and its according value which the series,

with which we are currently working, does not have, but is existent in another series.”

source: link

An approximate function is just another way to find missing values.

The approximation should then be used to “guess” the missing values.

As an accepted definition approximation is a selection of a function from a well-defined set of classes that closely matches a target function AKA “which approximates”

The function can be chosen in two primary ways. First by numerical analysis and second by building up the target function.

Wiki about Function approximation

source: link

One can distinguish two major classes of function approximation problems:

1. First, for known target functions approximation theory is the branch of numerical analysis that investigates how certain known functions (for example, special functions) can be approximated by a specific class of functions (for example, polynomials or rational functions) that often have desirable properties (inexpensive computation, continuity, integral and limit values, etc.).

2. Second, the target function, call it g, maybe unknown; instead of an explicit formula, only a set of points (a time series) of the form (x, g(x)) is provided. Depending on the structure of the domain and co-domain of g, several techniques for approximating g may be applicable. For example, if g is an operation on the real numbers, techniques of interpolation, extrapolation, regression analysis, and curve fitting can be used. If the co-domain (range or target set) of g is a finite set, one is dealing with a classification problem instead.

Let’s talk on linear approximates and take one more step to define splines.

We are on a mission of finding missing values by approximation.

let’s try by linear approximates. Linear approximate just guessing value based on the value at the next lowest timestamp(y-value) and the value at the next highest timestamp(y-value) using the formula

the equation takes two neighboring points and finds missing x-value based on them. More specifically choose the next highest and next lowest value for a missing time stamp and interpolate value at missing x-value of a timestamp by using the above formula.

SPLINES

A spline is a cubic function vs linear function above. The spline is a third-degree polynomial function between two points also called the “knot” points (two points on {(x, y)} time-series) All points on {(x, y)} except points missing x-values are chosen to be knot points to fit third-degree polynomial function “spline” between every two-knot points. This function is then used to interpolate value at the missing x-value of a timestamp.

So for N given points, we will need N-1 spline functions Si(x) of the following form:

I would like to share three awesome resources i found to clear my concepts

1. https://slideplayer.com/slide/6100297/

2. https://slideplayer.com/slide/3238820/

3. https://slideplayer.com/slide/1506841/