Discriminant Analysis in Data Science
Discriminant Analysis in Data Science
Machine
Learning Unit-
2
The document covers Discriminant Analysis and its applications in data science, focusing on classification techniques such as Naive Bayes, Linear Discriminant Analysis (LDA), and
Logistic Re… Full description 89 pages
25
Discriminant Analysis Bayes
12 pages
Syllabus:
PDF No ratings yet
Legal 3 AI
Covariance Matrix, Fisher’s Linear discriminant, Generalized Linear Models, Interpreting the
learning where a model is trained on labeled data (known outcomes) and used to predict PDF No ratings yet
Examples:
33 pages
Detecting phishing emails (phishing/not phishing)
Predicting customer churn (churn-stop using a service/not churn) PDF No ratings yet
Module 3 -
Estimating ad clicks (click/no click) Naive Bayes
Classifier
Types:
23 pages
Instead of just assigning classes, models can output probability estimates (propensities) that PDF No ratings yet
Supervised
indicate how likely a record belongs to a particular class. Classification
3601
Logistic regression outputs log-odds, which are converted to probabilities.
39 pages
In Python’s scikit-learn, predict() gives classes, while predict_proba() gives
PDF No ratings yet
probabilities. 2.3 Bayes
The General Decision Process: Classification
cutoff.
20 pages
· ·
33 pages
From Scribd 89 pages 41 views
No ratings yet
Machine Learning Unit-2 PDF No ratings yet
Classification
2
19 pages
Sometimes, the problem can be recast into multiple binary problems using conditional
5 pages
It uses the probability of observing predictor values given an outcome (P(X | Y)) to PDF No ratings yet
Naïve
compute the probability of the outcome given predictors (P(Y | X)). Bayesian
This helps determine which class a new record most likely belongs to. Classifier…
48 pages
Exact Bayesian Classification (Conceptual Idea):
PDF No ratings yet
For each new record:
Classification
1. Identify all training records with the same predictor values (predictor profile). Problems
Johari…
2. Observe theclass distribution among these identical records. 39 pages
3. Assign the class that occurs most frequently (most probable class).
PDF No ratings yet
L3 (Week3)
Bayesian
Classifier
21 pages
The Naive Bayes approach overcomes this by assuming that predictors are PDF No ratings yet
ML 05
conditionally independent, allowing probability estimation even when exact matches
Bayesian
don’t exist. Classifier
19 pages
Example:
PDF No ratings yet
In predicting voting behaviour using demographic variables, even with a large dataset, it’s rare Bayes
Classifier
to find another record exactly matching a new individual’s detailed profile (e.g., gender,
ethnicity, income, location, voting history, family structure, marital status). 20 pages
Hence, exact Bayesian classification becomes impractical for high-dimensional data, PDF No ratings yet
202109131157
motivating the use of Naive Bayes, which assumes predictors are conditionally independent to
10D3708 -
estimate probabilities efficiently. Session 09-…
30 pages
5.1.2 The Naive Solution
PDF No ratings yet
TheNaive Bayesalgorithmis a probabilistic classifier based on Bayes’ theorem, which
Unit-3 AML
estimates the probability of a class given a set of predictor values. (Bayesian
Concept…
It is called “naive” because it assumes that all predictors areindependent of each other 40 pages
given the outcome — an assumption rarely true in real data, but onethat often works well
PDF No ratings yet
in practice. UNIT - IV
Instead of looking only at records that exactly match a new case (as in exact Bayes
169 pages
classification), Naive Bayes uses the entire dataset to estimate probabilities.
PDF No ratings yet
Bayesian
23 pages
Dept. of CSE-DS, RNSIT Smitha B A 3
PDF No ratings yet
Module 3 -
Classification
78 pages
10 pages
However, these probability estimates are often biased because of the naive independence PDF No ratings yet
o Then apply the standard Naive Bayes algorithm for categorical data. PDF No ratings yet
(Ebook) A
o Example: Age can be divided into bins such as <20, 20–40, 40–60, 60+.
Gentle
2. Assume a Probability Distribution: Introduction…
150 pages
o Model each numerical predictor using a known probability distribution
(commonly the normal distribution). PDF No ratings yet
Intro to
o Estimate the conditional probability ( ∣ = )using that distribution’s Classification
& Regression
parameters (mean and variance) computed from the training data. 42 pages
o This approach leads to Gaussian Naive Bayes, often used when predictors are PDF No ratings yet
continuous. Credit Card
Fraud
5.2 Discriminant Analysis Detection…
1 page
Linear Discriminant Analysis (LDA) is the most common form of discriminant
PDF 0% (1)
analysis.
AZ-900
Fisher’s original method (1936) differs slightly from modern LDA, but the underlying Latest Exam
Dumps
mechanics are similar.
41 pages
Usage: Less common today due to more advanced methods like decision trees and
PDF No ratings yet
logistic regression. Six-Sigma
Case Study -
Relevance: LDA is still used in certain applications and has connections to other Quality…
Predictor variables are continuous and normally distributed (though LDA is fairly robust to 30 pages
′ =
2 pages
that best separates the two groups.
PDF No ratings yet
And Maximize the ratio: Decision
Authority
between
within
16 pages
where,
PDF No ratings yet
between : variation between group means (distance between groups) Tejas Rastogi
(Final
within : variation within groups (spread around means), adjusted by the covariancematrix Research…
Intuition: 47 pages
Naive Bayes
PDF No ratings yet
Assessment
of Poverty
Situation in…
9 pages
→ gives the best linear boundary for distinguishing the two classes. 12 pages
Problem
1 page
We want to predict whether a loan applicant will default (y =1) or pay off (y =0) using two
PDF No ratings yet
numeric predictors: NLP Case
Studynaman
borrower_score – measure of creditworthiness (0–1 scale)
payment_inc_ratio – ratio of monthly payment to income 23 pages
y =data['outcome']
PDF No ratings yet
Boosting
Experiential
#Fit LDA model Loyalty to…
9 pages
lda =LinearDiscriminantAnalysis()
[Link](X, y)
#Predict probabilities
pred =[Link](lda.predict_proba(X), columns=lda.classes_)
print(pred)
LDA creates a straight line that separates “paid off” and “default” regions:
= 0
Key Ideas:
o LDA works for continuous
or categorical predictors with
categorical outcomes.
o Uses thecovariance matrix
to compute a linear discriminant
function.
o Produces scores/weights
that classify each record into a
likely group.
o Core objective: maximize
between-group variance / minimize within-group variance for optimal class
separation.
outcome = 'outcome'
y = loan_data[outcome]
logit_reg.fit(X, y)
o Sometimes, a log link is used instead of a logit, but results are often similar in
practical cases.
While logistic regression is the most common GLM and widely applicable, using other GLMs
(e.g., Poisson, Gamma) requires deeper statistical understanding, as these models involve more
complex assumptions and are sensitive to data characteristics.
5.3.4 Predicted Values from Logistic Regression
Inlogistic regression, the model predicts thelog-odds of the outcome being 1:
= log(Odds( = 1))
To convert this linear prediction into aprobability, the logistic response function is applied:
1
=
1 −
This transformation ensures that the predicted probabilities lie between 0 and 1.
InPython (scikit-learn):
Log-oddsare obtained using predict_log_proba().
Probabilities are obtained directly using predict_proba():
pred = [Link](logit_reg.predict_proba(X),
columns=loan_data[outcome].[Link])
[Link]()
The predicted probabilities indicate the likelihood of the outcome (e.g., loan default).
Typically, a cutoff of 0.5 is used to classify outcomes (≥0.5 → default, <0.5 → paid off).
However, when identifyingrare events, alower threshold may be chosen to improve detection
of the minority class.
The logistic regression coefficient represents the log of the odds ratio for the variable :
= log(odds ratio)
Hence,
odds ratio =
Example interpretations:
For a categorical variable purpose_small_business
with coefficient 1.21526,
.6 ≈ 3.4
Loans to small businesses are about 3.4 times more likely to default than credit card loans (the
reference category).
For a numeric variable like payment_inc_ratio with coefficient 0.08244,
.8 ≈ 1.09
Each unit increase in payment-to-income ratio increasesdefault odds by 9%.
For borrower_score with coefficient –4.61264,
−.66 ≈ 0.01
Borrowers with excellent creditworthiness have 100 times lower odds of defaulting compared
to those with poor credit.
Because coefficients are expressed on the log scale, a one-unit increase in the coefficient
corresponds to a multiplication of the odds by ≈ 2.72.
Specialized residual diagnostics (like deviance or Pearson residuals) are used to assess
model fit and identify outliers or influential observations.
Thus, while logistic regression retains the linear relationship in form, its estimation and
diagnostic procedures are fundamentally different from those of ordinary least squares
regression.
Fitting the Model:
Inlinear regression, the model is fit using least squares, and the quality of fit is measured with
metrics like RMSE and R-squared.
Inlogistic regression, however:
There is no closed-formsolution for the coefficients because the response is binary.
The model is fit using Maximum Likelihood Estimation (MLE), which finds the
parameter values that make the observed data most probable.
The logistic regression response is modeled as the log-odds of the outcome being 1,
rather than 0 or 1 directly.
MLE iteratively updates coefficients using algorithms like quasi-Newton optimization
or Fisher scoring, improving the fit at each step.
For most practitioners, the software handles the optimization, so it is sufficient to understand
that MLE finds thebest-fitting logistic model under certain assumptions.
Stepwise selection, interaction terms, spline terms, and generalized additive models
(GAMs) are applicable.
In R: gam() function with family='binomial'
In Python: [Link]() supports spline terms using bs() (B-splines).
4. Residual Analysis:
Residuals differ from linear regression due to the binary nature of the outcome.
Partial residuals help visualize the effect of a predictor and detect nonlinear
behavior.
In logistic regression, residuals lie in
two clouds corresponding to 0s and 1s
because the observed outcomes are
binary, while predictions are log-odds.
Partial residual plots can still identify
influential observations and nonlinear
patterns.
R supports partial residuals; Python requires custom implementation.
5. Note
Dispersion parameter in R summary is not relevant for logistic regression.
Residual devia nce and number of scoring iterations relate to maximum likelihood
fitting.
Key Takeaway: Logistic regression combines interpretability of coefficients, flexibility with
GLM extensions, and classification-based evaluation, but residual analysis and goodness-of-fit
metrics differ fundamentally from linear regression.
Predicted 1 Predicted 0
pred = logit_reg.predict(X)
true_y = y == 'default'
[[Link](false_pos), [Link](true_neg)]],
conf_mat
Important Note:
When 1s (positives) are rare, the false positive rate can dominate, making a predicted positive
much more likely to be anegative in reality. This phenomenon occurs in medical screening tests,
such as mammograms, where most positive results are false positives due to the rarity of the
condition.
Note: These metrics are especially valuable in cases with rare positive events, where overall
accuracy can be misleading.
5.4.7 Lift
Using AUC improves model evaluation over simple accuracy because it considers thetrade-off
between identifying positives (1s) and overall accuracy, but it does not fully solve rare-class
problems:
When positives are rare, a cutoff <0.5 may be necessary to avoid classifying all records
as 0.
o Example: Classifying records with probability ≥ 0.3 as 1 to catch more rare
events.
Lowering the cutoff increases recall for the rare class but also increases falsepositives.
Lift (or Gains) Metric:
Measures how much better the model performs in identifying 1s compared to random
selection.
Example: Top 10% of records by predicted probability may yield 0.3% positive rate vs.
0.1% if selected randomly → lift =3.
Lift chart / Gains chart:
o X-axis: Cumulative records (or deciles)
o Y-axis: Cumulative recall (percentage of 1s captured)
o Lift curve: Ratio of cumulative gains to the diagonal (random selection)
Useful for identifying optimal probability cutoff in practice, especially underresource
constraints.
Applications:
Direct mail marketing: Target top prospects efficiently.
Tax audits: Select returns most likely to be fraudulent given limited audit resources.
Marketing / political campaigns: Determine uplift—improvement in outcome due to
treatment A vs. B for individual cases.
Note:
Lift charts quantify model effectiveness for the rare class and help decide a practical
probability cutoff aligned with business or resource priorities.
5.5.1 Undersampling
When the dataset is large, oneeffective strategy to handleimbalancedclassesisundersampling
the majority class (0s):
o The dominant class often contains redundant records.
o Removing some of these records creates a more balanced dataset, improving
model performance and simplifying data preparation.
Benefits:
o Reduces computational burden.
o Makes it easier to explore and pilot models.
o Helps the model better learn patterns for the minority class (1s).
How much data is enough?
o Depends on the application.
o Generally, having tens of thousands of records for the less dominant class is
sufficient.
o If the classes are easily distinguishable, less data may suffice.
Example (Loan Data):
o Training set was balanced: 50% paid off, 50% defaulted.
o Predicted probabilities roughly split around 0.5.
o In the full dataset, only ~19% of loans were in default, illustrating the original
imbalance.
Undersampling is particularly useful when the majority class is overwhelming , allowing the
model to focus on learning the characteristics of the minority class effectively.
In Python:
predictors = ['payment_inc_ratio', 'purpose_', 'home_', 'emp_len_',
outcome = 'outcome'
drop_first=True)
y = full_train_set[outcome]
full_model.fit(X, y)
We take content rights seriously. Learn more in our FAQs or report infringement here.
We and our 41 IAB TCF partners store and access information on your device for the following purposes: store and/or access information on a device, advertising and content measurement, audience research, and services
development, personalised advertising, and personalised content.
Personal data may be processed to do the following: use precise geolocation data and actively scan device characteristics for identification.
Our third party IAB TCF partners may store and access information on your device such as IP address and device characteristics. Our IAB TCF Partners may process this personal data on the basis of legitimate interest, or with
Customize Your Choices
your consent. You may change or withdraw your preferences at any time by clicking on the cookie icon or link; however, as a consequence, you may not see relevant ads or personalized content.
Our website may use these cookies to:
Measure the audience of the advertising on our website, without profiling Accept All
Display personalized ads based on your navigation and your profile
Personalize our editorial content based on your navigation
Allow you to share content on social networks or platforms present on our website Reject All
Send you advertising based on your location
Privacy Policy
Third Parties