# Trend Prediction Service¶

## Idea¶

The Trend Prediction Service predicts future values for time series using linear and nonlinear regression models. It is a forecasting framework, that has many useful applications in the area of Process & Condition Monitoring.

The service enables the user perform the following tasks:

- Predictive maintenance: A component's lifetime may be reached in the short-term future.
- Monitoring of processes: Prediction of remaining time to prevent unwanted process states.
- Seasonality and trend removal as preparation for other data analytics tasks.

## Access¶

For accessing this service you need to have the respective roles listed in Analytics Services roles and scopes.

## Basics¶

The Prediction Service is a data-driven approach that can be applied to univariate (single input variable) or multivariate (multiple input variables) time-series data. The predicted output is always univariate and written into a single target variable.

The service provides the functionality required for estimating the relationships between the variables of a given time series in order to make predictions based on the trained model. These predictions can then be used for reasoning about the process represented by the time series.

The trained models are based on a linear or polynomial regression.

### Linear regression¶

Linear regression assumes a linear dependence between a single target variable (y) and one or more independent input variables (e.g., time) (x_{1}, x_{2}, …):

y = b_{0} + b_{1}x_{1} + b_{2}x_{2} + … + b_{n}x_{n}

For a single independent variable x, the model is given by y = b_{0} + b_{1}x_{1}.

While not very complex, the approach has proven to be a powerful method for early detection of the potential faults. The results produced by the algorithm are both easy to interpret and to visualize.

In the case of the multivariate input, the algorithm expects that all independent variables are available at any time.

### Polynomial regression¶

Polynomial regression assumes a polynomial (of a given degree) dependence between a single target variable (y) and one or more independent input variables (e.g., time).

For a single independent variable x, the relationship is given by y = b_{0} + b_{1}x + b_{2}x^{2} + … + b_{n}x^{n}.

For a 3 independent variables x and a polynomial degree of 2, we have a model like

y = b_{0} + b_{1}x_{1}^{2} + b_{2}x_{2}^{2} + b_{3}x_{3}^{2} + b_{1}_{2}x_{1}x_{2} + b_{1}_{3}x_{1}x_{3} + b_{2}_{3}x_{2}x_{3}.

This approach can capture more complex relationships between the variables than a linear model at the expense of an increased computational complexity and a need of specifying the degree of a polynomial to be fitted.

In the case of the multivariate input, the algorithm expects that all independent variables are available at any time.

## Features¶

The Trend Prediction Service exposes its API for realizing the following tasks:

- Train (fit) a regression model
- Predict future values
- Train & predict in one request
- Get all regression models of an entity
- Get a regression model by ID
- Delete a regression model

## Example Scenario¶

The manager of a brewery wants to predict the yearly energy consumption of a new production line.

The manager collects time series data with the relevant energy consumption of the new production line, feeds the Trend Prediction Service API with this time series and evaluates the predicted future consumption.

## Related Links¶

## Any questions left?

*Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement*.