# How can a polynomial regression model be fit to understand non-linear trends in data in Python?

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

When regression models are being built, multicollinearity is checked for. This is because we need to understand the correlation present between all different combinations of continuous variables. If multicollinearity exists between the variables, we have to make sure that it is removed from the data.

The data in real world is usually non-linear. We need to find mechanisms to fit such non-linear data to the model. We will be using Anscombe’s dataset to visualize this data.

The ‘implot’ function is used with non-linear data −

## Example

import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
sb.lmplot(x = "x", y = "y", data = my_df.query("dataset == 'II'"),order = 3)
plt.show()

## Explanation

• The required packages are imported.
• The input data is ‘anscombe’ which is loaded from the seaborn library.
• This data is stored in a dataframe.