MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# Explain AR modelling of time series?

# Explain AR modelling of time series?

This recipe explains AR modelling of time series

Autoregression modeling is a modeling technique used for time series data that assumes linear continuation of the series so that previous values in the time series can be used to predict futures values. It includes the idea of 'lag variables'.

So this recipe is a short example on what is AR modelling of time series. Let's get started.

```
import numpy as np
import pandas as pd
from statsmodels.tsa.ar_model import AR
```

Let's pause and look at these imports. Numpy and pandas are general ones. Here statsmodels.tsa.ar_model is used to import autorregressive library for building of model.

```
df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/a10.csv', parse_dates=['date'])
df['value'] = np.log(df['value'])
df['value'] = df['value'].diff()
df = df.drop(df.index[0])
df.head()
```

Here, we have used one time series data from github. Now, since this data is progressing and, we have normalized the set and taken difference so as to have a stationary series.

Now our dataset is ready.

```
train_data = df[1:len(df)-12]
test_data = df[len(df)-12:]
```

Here we have simply split data into size of 12 and rest elements

```
model = AR(train_data.value)
model_fitted = model.fit()
```

We have simply build an AR model on our dataset and fit it.

```
print('coefficients',model_fitted.params)
predictions = model_fitted.predict(start=len(train_data), end=len(train_data) + len(test_data)-1)
print(predictions)
```

Here, we have printed the coeffiecient of model and the predicted values.

Once we run the above code snippet, we will see:

Scroll down the ipython file to visualize the output.

In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Build your own image similarity application using Python to search and find images of products that are similar to any given product. You will implement the K-Nearest Neighbor algorithm to find products with maximum similarity.

In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.