0% found this document useful (0 votes)
33 views11 pages

Lab5 ML Eac22050

Uploaded by

am.en.u4eac22015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views11 pages

Lab5 ML Eac22050

Uploaded by

am.en.u4eac22015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

19EAC381 Machine Learning with Python

Name: PARTTHIV MURALI R P Roll no.: AM.EN.U4EAC22050


DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING

19EAC381 MACHINE LEARNING WITH PYTHON

LABSHEET 5

Logistic Regression

Course Outcome: CO3 Date: - -

Aim: (Objective)

• To implement logistic regression system with the help of built-in library


functions and applies on real data sets for classification.
• Using performance evaluation metrics, evaluate the performance of logistic
regression on the given data.

Introduction:

Logistic regression is a supervised machine learning algorithm commonly used for


classification tasks. It predicts the probability of an instance belonging to a specific
class by applying a nonlinear function to the output of linear regression, mapping
continuous input values to probabilities between 0 and 1. The sigmoid function is
typically used for this purpose due to its range and properties, converting input
values to a probability scale. Optimization techniques, such as gradient ascent, are
applied to minimize the error and improve prediction accuracy.

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:

Applied logistic regression to predict the likelihood of a person developing


cardiovascular disease (CVD) within ten years based on health and demographic
features such as age, sex, smoking status, and blood pressure. By encoding
categorical variables and scaling the features to a consistent range, we ensured that
the logistic regression model could effectively interpret the data. After training the
model, we used it to predict CVD outcomes on test data, producing binary results
(0 or 1) indicating the absence or presence of CVD risk.

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:

Logistic regression is called "regression" rather than "classification" because it


models the probability of a given instance belonging to a specific class, rather than
directly classifying it. Logistic regression uses a linear equation to predict a
continuous outcome in the form of probabilities, which are then converted to
binary classes (like 0 or 1) through a thresholding process (typically at 0.5).

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy