- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
How can non-linear data be fit to a model in Python?
We will be using the Seaborn library, that helps in visualizing data.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 this non-linear data.
Here’s the example −
import pandas as pd import seaborn as sb from matplotlib import pyplot as plt my_df = sb.load_dataset('anscombe') sb.lmplot(x="x", y="y", data=my_df.query("dataset == 'I'")) plt.show()
- The required packages are imported.
- The input data is ‘anscombe’ which is loaded from the seaborn library.
- This data is stored in a dataframe.
- The ‘load_dataset’ function is used to load the iris data.
- This data is visualized using the ‘implot’ function.
- Here, the dataframe is supplied as parameter.
- Also, the x and y values are specified.
- This data is displayed on the console.
- Related Articles
- How can a polynomial regression model be fit to understand non-linear trends in data in Python?
- How can Tensorflow be used to fit the data to the model using Python?
- How can Tensorflow be used to fit the augmented data to the model?
- How can model be fit to data with Auto MPG dataset using TensorFlow?
- How can Tensorflow be used to compile and fit the model using Python?
- How can Tensorflow be used to compare the linear model and the Convolutional model using Python?
- How can TensorFlow used to train a linear model using Python?
- How can Tensorflow be used with the flower dataset to compile and fit the model?
- How can Tensorflow and pre-trained model be used to visualize the data using Python?
- How can ‘implot’ function be used to fit values to data if one of the variables is a discrete value in Python?
- How can a linear relationship be visualized using Seaborn in Python?
- How can Tensorflow be used to evaluate a CNN model using Python?
- How can Tensorflow be used to create a sequential model using Python?
- How can Keras be used to reload a fresh model from the saved model using Python?
- Difference between Linear and Non-linear Data Structures