LAB4_ML_EAC22050
LAB4_ML_EAC22050
LABSHEET 4
Linear Regression
Aim: (Objective)
Introduction:
Linear regression is widely used for predictive analysis by modeling the relationship between
a dependent variable and one or more independent variables. In this session, we have focused
on utilizing Python libraries such as NumPy, Pandas, Seaborn, and Matplotlib for data
preprocessing, model training, evaluation, and visualization. The dataset is divided into
training and testing sets to build a regression model, followed by evaluating the model's
performance using metrics like R-squared, Mean Absolute Error, and Root Mean Squared
Error. Finally, a regression plot is generated to visualize the linear relationship between
variables and assess the model's fit.
Lab sheet 4 35
19EAC38 Machine Learning with Python
Lab sheet 4 36
19EAC38 Machine Learning with Python
Inference:
Lab sheet 4 37
19EAC38 Machine Learning with Python
Lab sheet 4 38
19EAC38 Machine Learning with Python
Lab sheet 4 39
19EAC38 Machine Learning with Python
Inference:
This linear regression analysis on the CO₂ emissions dataset, we observe that the
model effectively captures the relationship between vehicle features and CO₂
emissions. The performance metrics, including Mean Absolute Error (MAE),
Mean Squared Error (MSE), and Root Mean Squared Error (RMSE), indicate the
model’s accuracy in predicting emission levels based on vehicle characteristics.
The correlation heatmap further supports these findings, revealing strong
correlations between certain features and CO₂ emissions. The regression plot
shows a clear trend, validating the model's predictions. Overall, this analysis
demonstrates linear regression's utility in estimating CO₂ emissions and highlights
the influence of specific vehicle attributes on environmental impact.
Lab sheet 4 40
19EAC38 Machine Learning with Python
Lab sheet 4 41
19EAC38 Machine Learning with Python
Lab sheet 4 42
19EAC38 Machine Learning with Python
Lab sheet 4 43
19EAC38 Machine Learning with Python
Lab sheet 4 44
19EAC38 Machine Learning with Python
Lab sheet 4 45
19EAC38 Machine Learning with Python
Lab sheet 4 46
19EAC38 Machine Learning with Python
Lab sheet 4 47
19EAC38 Machine Learning with Python
Inference:
The implementation of linear regression with gradient descent offers insight into
optimizing model parameters by iteratively minimizing the cost function. By
adjusting the model’s weights to reduce the error between predicted and actual
values, gradient descent efficiently converges to an optimal solution, even for large
datasets. The iterative process demonstrates how gradient descent achieves
accurate predictions without requiring closed-form solutions, making it highly
scalable. This approach reinforces the effectiveness of gradient descent in linear
regression for data-driven tasks, where learning rates and convergence play crucial
roles in the model's performance and accuracy.
Lab sheet 4 48