What is Durbin Watson test?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

# What is Durbin Watson test?

This recipe explains what is Durbin Watson test

0

## Recipe Objective

What is Durbin Watson test? How to perform it in python.

Durbin Watson test includes statistics, and it is equal to 2*(1-r), where r is autocorrelation between residual. When test statistic equals 2 no autocorrelation. When closer to 0 evidence of positive correlation, when closer to 4 evidence of negative correlation.

Durbin watson test is defined as:-

## Step 1- Importing Libraries.

``` import pandas as pd from statsmodels.formula.api import ols from statsmodels.stats.stattools import durbin_watson```

``` df= pd.read_csv('/content/sample_data/california_housing_train.csv') df.head()```

## Step 3- Applying ordinary Least Squares(OLS).

Before applying durbin-watson test we have to apply OLS on some column particularly.

``` model=ols('total_bedrooms ~ housing_median_age + total_bedrooms + households',data=df).fit() print(model.summary()) ```

## Step 4- Applying Durbin-watson test.

``` durbin_watson(model.resid)```

As we can see the value is closer to 0 it is more evident of positive correlation.

#### Relevant Projects

##### Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

##### Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

##### Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

##### Census Income Data Set Project - Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based on census data.

##### Ecommerce product reviews - Pairwise ranking and sentiment analysis
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.

##### Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

##### Loan Eligibility Prediction using Gradient Boosting Classifier
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.

##### Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

##### Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

##### Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.