Dav Exp3
Dav Exp3
EXPERIMENT NO.3
Aim: Multiple linear regression in python.
Regression models are used to describe relationships between variables by fitting a line to
the observed data. Regression allows you to estimate how a dependent variable changes as
the independent variable(s) change.
Multiple linear regression is used to estimate the relationship between two or more
independent variables and one dependent variable. You can use multiple linear regression
when you want to know:
1. How strong the relationship is between two or more independent variables and one
dependent variable (e.g. how rainfall, temperature, and amount of fertilizer added
affect crop growth).
2. The value of the dependent variable at a certain value of the independent variables
(e.g. the expected yield of a crop at certain levels of rainfall, temperature, and
fertilizer addition).
EXPERIMENT NO.3
Aim: Multiple linear regression in python.
Input code:
# Import necessary libraries
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
Output:
Model Parameters:
Intercept: 4.51
Coefficients: X1=2.33, X2=3.14, X3=1.59
Mean Squared Error: 2.10
R2 Score: 0.88