Regression analysis is used to predict continuous outcomes from the given data. It uses features from data to fit a line that models the relationship
Regression also helps us understand how the features influence a target variable. The Target value will always be a continuous value in regression modelling.
As you know, in Machine Learning, we have features (X) and Target value (y). So you plot the features using matplotlib.pyplot module and you can leverage scatterplot to plot the relationship.
Linear Regression is one of the type of regression model. Its part of SciKit learn package.
from sklearn.linear_model import LinearRegression as lr
then you follow the steps:
- Initiate the model
- Fit the model
- Predict the model
- Plot the model
When plot for linear regression line, always plot your training data with predicted data
plt.plot(X, prediction, color="red") #color for visual representation