0% found this document useful (0 votes)
7 views4 pages

Logistic Regression and SVM Tutorial

This document is a tutorial on Logistic Regression and Support Vector Machines (SVMs), covering key concepts, model specifications, and applications in predicting outcomes based on various attributes. It includes true/false questions, probability calculations, model interpretations, and practical examples related to predicting income, admission to UCLA, and cardiovascular disease risk. Additionally, it discusses the optimization of SVMs and their decision boundaries.

Uploaded by

Pearson Rangani
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)
7 views4 pages

Logistic Regression and SVM Tutorial

This document is a tutorial on Logistic Regression and Support Vector Machines (SVMs), covering key concepts, model specifications, and applications in predicting outcomes based on various attributes. It includes true/false questions, probability calculations, model interpretations, and practical examples related to predicting income, admission to UCLA, and cardiovascular disease risk. Additionally, it discusses the optimization of SVMs and their decision boundaries.

Uploaded by

Pearson Rangani
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

Tutorial 5B: Logistic Regression and SVMs

1. Specify whether each of the following statements are True or False:

a. Logistic regression is a supervised machine learning algorithm True


b. Logistic regression is used to perform regression False
c. It is possible to apply a logistic regression algorithm to predict the value of a
target variable which has 3 or more classes True

2. To what range is the probability restricted for the outcome prediction in logistic
regression?

a. (0, inf)
b. (-inf, 0)
c. (0, 1)
d. (-inf, inf)

3. Which of the following functions are used to transform the categorical target variable Y
in to a continuous-valued quantity?

a. Log link function


b. Logit link function
c. Log likelihood function.
d. Log odds function

4. Suppose a set of reasonably clean sample records was extracted from the 2020 census
database in the US. We are interested in predicting whether a person makes over $50K a
year, using two binary, nominal attributes viz:
• depending on whether they are male or female (X1), and
• depending on whether or not they have completed a tertiary qualification (X2).

Suppose we model the two features and label Y ∈ {0, 1} where Y = 1 indicates a person
makes over 50K. In the figure below we show three positive samples (“+” for Y = 1) and
one negative samples (“-” for Y = 0).

For predicting samples in the figure above, which model is better: Logistic Regression or
Linear Regression? Explain why. Logistic regression – used to model the probability
associated with a categorical variable that values between 0 and 1, which is consistent with
the target space of Y in this example, and is able to model using numeric and/or categorical
attributes. Linear regression is used to predict any continuous value.

5. Suppose the probability that a house on the market sells for the asking price is 0.72:

a. What are the odds in favour of the house selling for the asking price?

0.72/(1-0.72) = 2.79

b. What are the odds that the house does NOT sell for the asking price?

(1-0.72)/0.72 = 0.39

6. The odds of a mushroom being poisonous is 2.68. What is the probability that the
mushroom is poisonous?

7. Data from the UCLA undergraduate school has 3 variables called admit, GRE score, and
GPA score. Our aim is to build a model to predict the probability of a student getting
admitted to UCLA, if we are given his profile (i.e his GRE and GPA scores).

We used logistic regression to fit a model to the data. The model results are given in
the table below:

Variable Estimate P-value


Intercept -3.989 0.00047
GRE 0.002 0.03847
GPA 0.804 0.01539

a. Determine the estimated logistic regression model i.e. write down the model equation.

b. Interpret the parameter estimates of the model.

c. Determine the estimated odds ratio for 4 units increase in GPA score, and interpret
this value.
d. Consider a student who achieved a score of 790 in GRE, and a score of 3.8 in GPA.
Use the model to predict whether or not the student will be admitted in to UCLA.

8. Logistic regression was used to model the likelihood of a man having cardiovascular
disease (CVD) based on their age, weight and exercise habits. Using a sample of men of
the same race, information was collected on their age (in years), weight (in KG) and
exercise habits (average amount of time spent exercising per week in hours), as well as
whether they had CVD or not.

a. Specify the response variable and independent variables.

Suppose the following results were obtained for the logistic regression model:

b. Specify the fitted model.

c. Which variable(s) has/have a significant positive association with the likelihood of


having CVD?

d. Interpret the estimate corresponding to the effect of exercise.

e. Determine the odds of having CVD for an increase of 2 hours of exercise per week
on average.

f. Classify the CVD status of a 35 year old man who weighs 70kg and exercises for 30
minutes per week, on average.

See powerpoint slides for solutions to all of Q8-12

9. Why do support vector machines usually map examples to a higher dimensional space?

10. Does the optimization procedure of a SVM always find the maximum marginal
hyperplane, assuming that the data are linearly separable?

11. Consider the plot of training data given below:

a. Draw 3 possible decision boundaries (in a solid line) and indicate the margins
associated with each of them (in a dotted line) as well as their different sets of
associated support vectors (circled):

b. Out of the 3 possible decision boundaries that you have drawn in the previous
example, which one could be the MMH?

12. A support vector machine is to be used to predict whether a patient is at risk for cardio
vascular disease (CVD). The class labels are +1 for “high risk” and -1 for “low risk”.
Three attributes were considered: age, BMI and blood pressure. The observations for
these attributes have been standardised. The table below gives the support vectors and
Lagrange multipliers:

a. How many weights will there be in the trained model?


b. Determine the trained support vector machine i.e. the equation for the MMH.

c. Based on the trained SVM, discuss the importance of the variables in terms of the
risk of CVD

d. Using the trained SVM, classify the risk of the following men:

Common questions

Powered by AI

Maximum likelihood estimation (MLE) is significant in logistic regression because it provides a method for estimating coefficients that best explain the observed data by maximizing the probability of the observed outcomes given the model parameters. Unlike least squares estimation, which minimizes the sum of the squared deviations for continuous outcomes, MLE focuses on maximizing the probability that the logistic model predicts the binary outcomes correctly, accommodating the logistic function's non-linearity and addressing issues inherent to binary response data .

In logistic regression, the 'logit link function' is used to transform a categorical target variable into a continuous-valued quantity. This transformation is necessary to model the log-odds of the probability of the target variable being a particular class. By applying the logit link function, it converts the probability to a continuous range of values from negative to positive infinity, which better aligns with the linear combination of features typically used in regression analysis, allowing for efficient parameter estimation .

Logistic regression is more suitable than linear regression for binary classification because it predicts probabilities, which are naturally bounded between 0 and 1. Linear regression can predict values outside this range, making it inappropriate for classification tasks where outcomes are binary (e.g., 0 or 1). For example, predicting whether a person earns over $50K annually fits a binary outcome (yes or no). Here, logistic regression uses the logistic function to map predictions to the (0,1) range, ensuring that they are interpretable as probabilities, whereas linear regression could yield invalid predictions outside this range .

Support vector machines handle non-linearly separable data by introducing slack variables that allow some misclassifications. These relax the strict separation condition, enabling the SVM to maintain a soft margin that accounts for overlap between classes. Regularization plays a pivotal role by controlling the trade-off between maximizing the margin and minimizing classification errors. It ensures that the SVM does not overfit the data, achieving a balance between accuracy and generalization by penalizing overly complex models .

The odds ratio interpretation of logistic regression coefficients provides insights into how a one-unit increase in a predictor variable affects the odds of the outcome occurring. It is calculated by exponentiating the coefficient of the variable. For example, if the coefficient of GPA score is 0.804, the odds ratio is exp(0.804) = 2.23. This means that for each one-unit increase in GPA, the odds of a student being admitted to UCLA increase by a factor of 2.23, indicating the importance of GPA relative to other features in the model .

SVMs map data to a higher-dimensional space to make data linearly separable, which may not be possible in the original space. This transformation allows SVMs to construct a maximum margin hyperplane with the greatest separation between different class data points. The 'kernel trick' is often used to perform this mapping without explicitly computing the coordinates in higher dimensions. This mapping is essential because it enables SVMs to solve complex classification problems by effectively identifying and utilizing nonlinear patterns within data .

Logistic regression calculates the likelihood of an event by modeling the log-odds as a linear combination of predictor variables. The probability of a house selling at the asking price, for instance, can be derived as a logistic function of these odds. If the model predicts 0.72 as the probability, the odds are computed as 0.72/(1-0.72) = 2.57, indicating the house is over 2.5 times as likely to sell as not. This odds interpretation allows decision-makers to understand and compare probabilities relatively .

The choice of kernel function significantly impacts the performance of an SVM model as it determines the feature space where the algorithm works to find the decision boundary. Different kernels like linear, polynomial, and radial basis function (RBF) cater to different types of data distributions and complexities; thus, selecting an appropriate kernel is crucial for capturing the underlying data structure. Inappropriate choice can lead to underfitting or overfitting, affecting classification accuracy by either misrepresenting data relationships or modeling noise as patterns .

Interpreting logistic regression parameters allows decision-makers to quantify the impact of academic scores on admission probabilities. For instance, a positive coefficient for GRE scores indicates that higher GRE scores increase the chances of admission, quantified by the odds ratio. This transformation of coefficients into interpretable metrics like odds ratios helps universities understand the relative importance of different scores, making data-driven decisions for student admissions more transparent and supported by objective analysis .

Logistic regression can handle a target variable with more than two classes through a method known as multinomial logistic regression. In this scenario, the algorithm models the probabilities of multiple outcomes by estimating separate regression equations for each class against a reference class. Challenges include increased complexity and computation, as well as a need for more data to accurately estimate parameters for each class. Handling imbalanced class distributions can also be challenging, as it might require additional techniques to ensure accurate predictions .

You might also like