# How can ‘implot’ function be used to fit values to data if one of the variables is a discrete value 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.

This is where functions ‘regpot’ and ‘implot’ come into play. They help visualize a linear relationship between variables in linear regression.

The ‘regplot’ function accepts values for variables ‘x’ and ‘y’ in a variety of formats, and this includes numpy arrays, pandas series objects, references to variables or values from a pandas dataframe.

On the other hand, the function ‘implot’ requires the user to pass a specific parameter for data, and the values for variables ‘x’ and ‘y’ need to be strings. This type of data format is known as long-form data. Here’s the example −

## Example

import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
sb.lmplot(x = "size", y = "tip", data = my_df)
plt.show()

## Explanation

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