Lab5 ML Eac22050
Lab5 ML Eac22050
LABSHEET 5
Logistic Regression
Aim: (Objective)
Introduction:
Exercises:
Lab sheet 5 49
19EAC381 Machine Learning with Python
Lab sheet 5 50
19EAC381 Machine Learning with Python
Lab sheet 5 51
19EAC381 Machine Learning with Python
Lab sheet 5 52
19EAC381 Machine Learning with Python
Lab sheet 5 53
19EAC381 Machine Learning with Python
Lab sheet 5 54
19EAC381 Machine Learning with Python
Inference:
Lab sheet 5 55
19EAC381 Machine Learning with Python
Lab sheet 5 56
19EAC381 Machine Learning with Python
Lab sheet 5 57
19EAC381: Machine Learning with Python
LABSHEET 5 55
19EAC381: Machine Learning with Python
Inference:
The logistic regression model is trained to classify wine types based on various
features from the dataset. The data is first split into training and testing sets with
80% allocated for training and 20% for testing. After training the model on X_train
and y_train, predictions are made on X_test, and a confusion matrix is generated to
visualize the performance of the classifier. The confusion matrix provides insights
into true positives, true negatives, false positives, and false negatives, indicating
the model’s accuracy in correctly classifying wine types. Finally, the accuracy
score is calculated, which gives an overall measure of the model's effectiveness in
predicting the correct wine types based on its learned features.
Theory Questions:
Linear and logistic regression differs in purpose, output, function, and error
minimization. Linear regression predicts continuous outcomes by producing a
continuous output based on a linear relationship and minimizing Mean Squared
Error (MSE). Logistic regression, used for classification tasks, outputs a
probability between 0 and 1, which is thresholded for class labels. It applies a
logistic (sigmoid) function to compress output into a probability. Thus, linear
regression suits regression tasks, while logistic regression is adapted for
classification.
LABSHEET 5 56