SlideShare a Scribd company logo
LOGISTIC REGRESSION
What is Analytics?
Skill Set
Tool Set
Salary Structure
Machine_Learning.pptx
ML in a
Nutshell
• Tens of thousands of machine learning algorithms
• Hundreds new every year
• Every machine learning algorithm has three
components:
• Representation
• Evaluation
• Optimization
Representation
(Algorithms)
• Decision trees
• Sets of rules / Logic programs
• Instances
• Graphical models (Bayes/Markov
nets)
• Neural networks
• Support vector machines
• Model ensembles
• Etc.
Evaluation(Model fit stats
calculation)
• Accuracy
• Precision and
recall
• Squared error
• Likelihood
• Posterior
probability
• Cost / Utility
• Margin
• Entropy
• K-L divergence
• Etc.
Optimization(Methods for Parameters
Estimation)
• Combinatorial
optimization
• E.g.: Greedy search
• Convex optimization
• E.g.: Gradient descent
• Constrained
optimization
• E.g.: Linear programming
ML in
Practice
• Understanding domain, prior knowledge, and goals
• Data integration, selection, cleaning, pre-
processing, etc.
• Learning models
• Interpreting results
• Consolidating and deploying discovered knowledge
• Loop
The
Learning
1
2
3
4
5
6
Machine
Learning
• How did our brain process the images?
• How did the grouping happen?
• Human brain processed the given images - learning
• After learning the brain simply looked at the new image and
compared with the groups classified the image to the closest
group - Classification
• If a machine has to perform the same operation we use
Machine Learning
• We write programs for learning and then classification, this is
nothing but machine learning
Machine
Learning
Learnin
g
algorith
m
TRAININ
G
DATA
Answer
Trained
machine
Query
The machine learning
framework
• Apply a prediction function to a feature representation of the image
to get the desired output:
Slide credit: L.
The Machine Learning
framework
y =
f(x)
output prediction function
Image feature
• Training: given a training set of labeled examples {(x1,y1), …, (xN,yN)}, estimate the
prediction function f by minimizing the prediction error on the training set
• Testing: apply f to a never before seen test example x and output the predicted value
y = f(x)
Methods includes Parametric Methods and Non-parametric Methods
Classification: predicting a
category
Some techniques:
- Naïve Bayes
- Decision Tree
- Logistic Regression
- SGD
- Support Vector Machines
- Neural Network
- Ensembles
• Decision Trees – rpart, party, tree, chaid
• Random Forest – randomForest, party
• Neural Networks – nnet, neuralnet,
RSNNS
• SVM and Kernel estimation – e1071,
kernalab
•Performance Evaluation -
ROCR Etc.
Classification
in R
Highest market share
Data handling and
analytics capabilities
Easy to use/ learn
Why R/Python
Table of Contents
1) Business Problem
2) Base knowledge
3) Difference between Linear Regression & Logistic Regression
4) Logistic Regression
5) Logistic Model Development
6) Model Validation
7) Hands on – R/Python
8) Quizes
9) Case Solution
Case study- Banking
Business Problem
We have data for 900 banking customers, whether an applicant was rated as “Good
Credit/Non-Default” or “Bad Credit/Default” based on some given attributes.
Analytical Problem: We need to analyze and do exploratory data analysis and build
model
Here is the Definitions of the columns of
the data:
⮚ Age-Age of Applicant
⮚ Education- Range 1-5
⮚ Employment – Range 0-33
⮚ Address – Range 0-34
⮚ Income – Monthly Salary(‘Thousands)
⮚ Debtinc – Debt-to-Income Ratio
⮚ Credit debt – Credit card debt(credit loans)
⮚ Other debts – Any other loan liabilities
⮚ Default – 1(Loan default), 0 (Non-Default)
1. Understanding business problem
2. What is Default/Non-Default
3. Need of predictive model
4. Other problems that can be answered by similar scenario
5. What is Target/Dependent Variable
6. What are independent variables
7. Exploratory Analysis
8. Understanding Logistic Regression
Base knowledge/Applications
Models can be developed in domains of risk, marketing or collections.
• Risk: Models to assess the credit worthiness of an application
✓ Credit card & Loans: Bad vs. Good
✓ Fraud Detection: Fraud Vs. Not Fraud
• Collections: Models to identify cardholders that are likely to default and thus need collection effort (Payment
Projection Models)
✓ Credit card & Loans: Default vs. Non Default
• Insurance: Models to identify claims that are Fraud or Not Fraud
• Marketing & Sales: Models to identify to responders to promotional campaigns
✓ Marketing: Response Vs. Non Response
✓ Sales: Buying Vs. Not Buying
• Operations: Models to identify to employees who attrite
✓ Operations: Attrition Vs. Retention
• Website: Models to identify to weather visitor will click or not
✓ Website: Click Vs. Not Click
• Gaming: Models to identify to who will win
✓ Gaming: Win Vs. Loss
• Health Care: Models to identify to cure or not cure
✓ Health Care: Cure Vs. Not Cure
Logistic Regression Modeling Applications
Meaning of Modeling
By “Modeling” we mean developing set of equations or mathematical formulation by which we can :
• Predict certain events
• Identify the drivers of certain events based on some explanatory variables For example, we can build
models to predict drivers of sales, risk of a borrower.
Historical
Data
Statistical
Analyse
s
Predict
Future Events
Bad
25
Your
Company
Recall: Modeling Process
3) Model Development
• Multivariate Analysis
• Variable Creation
• Variable Transformation and Binning
• Multicollinearity Check
• Variable Selection
• Technique Selection
Building Blocks of
the Modeling
Process
2) Data Analysis
• Univariate Analysis
• Extreme value treatment
• Missing Value Treatment
• Graphical Representation
1) Data Preparation
• Data Extraction
• Data Collation
• Data Sampling and holdouts
4) Model Validation
• Performance Analysis and charting
• Multiple model comparison
• Out of Sample Validation
What ?
Regression is formulating a functional relationship between a set of independent or Explanatory
variables (Xs) with a Dependent or Response variable (Y).
Y=f(X1, X2, X3,…,Xn)
Why ?
▪Knowledge of Y is crucial for decision making.
▪ Will he/she buy or not?
▪ Shall I offer him/her the loan or not?
▪X is available at the time of decision making and is related to Y, thus making it possible to have
a prediction of Y.
Recall: What is Regression?
ÐLogistic Regression
Continuous Binary (1/0)
ÐOrdinary Least
Squares Regression
Y
Sales Volume, Claim Amount, Number of
Equipments, % Increase in Growth, etc.
Buy/No Buy, Delinquent/Non Delinquent,
Growth/No Growth, etc.
Recall: Types of Regression
Quiz 1
Is Logistic regression mainly used for Regression?
True False
A B
1. A
2. B
Linear Vs Logistic
Why Not Linear?
Logistic Regression
Logistic Regression
Quiz 2
Which of the following methods do we use to best fit the data in Logistic Regression?
Least Square Error Maximum Likelihood
A B
Jaccard distance Both A and B
C D
1. A
2. B
3. C
4. D
Model Development
Steps of Modelling
Outlier
treatment
•Box Plot
•Percentile(99)
Missing
value
treatment
Normalizatio
n of data
Handling
multi-
collinearity
•Performed VIF
Dummy
variable
creation
•Handle categorical variables
Logisitc
Model
• Variable Selection
• Optimising Model
EDA on banking customer data
Missing Value Analysis
Console Output
Outlier Detection: identify abnormal
patterns
Example: identify engine
anomalies Features:
- Heat generated
- Vibration of engine
Outlier Detection Target Function: outlier
factor
Outlier factor (0…1)
Some techniques:
- Statistical
techniques
- Local outlier factor
- One-class SVM
ID Total$ Age City OF
101 $200 25 SF 0.1
102 $350 35 LA 0.05
103 $25 15 LA 0.2
… … … … 0.1
0.9
0.2
0.15
0.1
Quiz 3
Which of the following measures of central tendency will always change if a single
value in the data changes?
Mean Median
A B
Mode All
C D
1. A
2. B
3. C
4. D
Multicollinearity
Quiz 4
A correlation between age and health of a person found to be -1.09. On basis of this
you would tell the doctors that?
The age is good predictor of health The age is poor predictor of health
A B
None of these
C
1. A
2. B
3. C
Min-Max Normalization
Min-Max Normalization
Logistic Procedure-Variable Significance
Logistic Procedure-Concordance
Association of Predicted Probabilities and Observed Responses
Percent Concordant 79.0
Percent Discordant 19.1
Percent Tied 1.9
Pairs 3627468
✓ Concordance is used to assess how well scorecards are separating the good and bad accounts in the development sample.
✓ The higher is the concordance, the larger is the separation of scores between good and bad accounts.
✓ The concordance ratio is a non-negative number, which theoretically may lie between 0 and 1.
Concordance Determination:
Among all pairs formed from 0 & 1 observations from the dependent variable, the % of pairs where the probability
assigned to an observation with value 1 for the dependent variable is greater than that assigned to an observation with
value 0.
Percentage of concordant pairs should be at least greater than 60.
Logistic Procedure-Confusion Matrix/ROC Curve
Solution
1. AUC of the model being 87% means that model have been able to distinguish between
defaulters and non-defaulters with 37% better than baseline/random model
1. Initial event rate i.e. default rate being 26% which is baseline result while Precision of
model being 55%, model have been able to provide 2x better lift.
Quiz 5
For the below confusion matrix, what is the recall?
1. 0.7
2. 0.8
3. 0.9
4. 0.95
Q & A
Machine_Learning.pptx
Thank You

More Related Content

PPTX
Insurance Churn Prediction Data Analysis Project
PPTX
Supervised learning
PPTX
Business Analytics.pptx
PPTX
Module_6_-_Datamining_tasks_and_tools_uGuVaDv4iv-2.pptx
PPTX
CHAPTER 11 LOGISTIC REGRESSION.pptx
PDF
Introduction to machine learning
PDF
Evans_Analytics2e_ppt_01.pdf
PDF
Intro_to_business_analytics_1707852756.pdf
Insurance Churn Prediction Data Analysis Project
Supervised learning
Business Analytics.pptx
Module_6_-_Datamining_tasks_and_tools_uGuVaDv4iv-2.pptx
CHAPTER 11 LOGISTIC REGRESSION.pptx
Introduction to machine learning
Evans_Analytics2e_ppt_01.pdf
Intro_to_business_analytics_1707852756.pdf

Similar to Machine_Learning.pptx (20)

PDF
Chapter 1 Introduction to Business Analytics.pdf
PPTX
Forecasting Using the Predictive Analytics
PPTX
MA- UNIT -1.pptx for ipu bba sem 5, complete pdf
PPTX
Bank Customer Churn Prediction- Saurav Singh.pptx
PDF
Machine Learning Project - Default credit card clients
PPTX
Introduction to Business Analytics---PPT
PPTX
A high level overview of all that is Analytics
DOCX
Credit Card Marketing Classification Trees Fr.docx
DOCX
Neural Network Model
PPT
Summer 07-mfin7011-tang1922
PDF
Chapter 4 Classification in data sience .pdf
PPTX
Introduction to machine learning and model building using linear regression
PDF
Analytics Types.pdfdvf ifbvuibugdfiubuibubufdibhdfiubfduibhfiuvdih
PPTX
Purchase Prediction for Insurance Company
PDF
PPTX
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
PPTX
Business analytics
PDF
Machine learning in credit risk modeling : a James white paper
PPT
Machine-Learning-Algorithms- A Overview.ppt
PPT
Machine-Learning-Algorithms- A Overview.ppt
Chapter 1 Introduction to Business Analytics.pdf
Forecasting Using the Predictive Analytics
MA- UNIT -1.pptx for ipu bba sem 5, complete pdf
Bank Customer Churn Prediction- Saurav Singh.pptx
Machine Learning Project - Default credit card clients
Introduction to Business Analytics---PPT
A high level overview of all that is Analytics
Credit Card Marketing Classification Trees Fr.docx
Neural Network Model
Summer 07-mfin7011-tang1922
Chapter 4 Classification in data sience .pdf
Introduction to machine learning and model building using linear regression
Analytics Types.pdfdvf ifbvuibugdfiubuibubufdibhdfiubfduibhfiuvdih
Purchase Prediction for Insurance Company
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
Business analytics
Machine learning in credit risk modeling : a James white paper
Machine-Learning-Algorithms- A Overview.ppt
Machine-Learning-Algorithms- A Overview.ppt
Ad

Recently uploaded (20)

PDF
Business Analytics and business intelligence.pdf
PDF
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
PPTX
Database Infoormation System (DBIS).pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
Managing Community Partner Relationships
PPTX
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
PPT
DATA COLLECTION METHODS-ppt for nursing research
PDF
Data Engineering Interview Questions & Answers Batch Processing (Spark, Hadoo...
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
importance of Data-Visualization-in-Data-Science. for mba studnts
PPT
ISS -ESG Data flows What is ESG and HowHow
PDF
Oracle OFSAA_ The Complete Guide to Transforming Financial Risk Management an...
PPT
Predictive modeling basics in data cleaning process
PDF
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
PPTX
Pilar Kemerdekaan dan Identi Bangsa.pptx
PDF
Optimise Shopper Experiences with a Strong Data Estate.pdf
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PDF
Introduction to the R Programming Language
PPTX
modul_python (1).pptx for professional and student
Business Analytics and business intelligence.pdf
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
Database Infoormation System (DBIS).pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Managing Community Partner Relationships
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
DATA COLLECTION METHODS-ppt for nursing research
Data Engineering Interview Questions & Answers Batch Processing (Spark, Hadoo...
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
importance of Data-Visualization-in-Data-Science. for mba studnts
ISS -ESG Data flows What is ESG and HowHow
Oracle OFSAA_ The Complete Guide to Transforming Financial Risk Management an...
Predictive modeling basics in data cleaning process
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
Pilar Kemerdekaan dan Identi Bangsa.pptx
Optimise Shopper Experiences with a Strong Data Estate.pdf
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Introduction to the R Programming Language
modul_python (1).pptx for professional and student
Ad

Machine_Learning.pptx

  • 7. ML in a Nutshell • Tens of thousands of machine learning algorithms • Hundreds new every year • Every machine learning algorithm has three components: • Representation • Evaluation • Optimization
  • 8. Representation (Algorithms) • Decision trees • Sets of rules / Logic programs • Instances • Graphical models (Bayes/Markov nets) • Neural networks • Support vector machines • Model ensembles • Etc.
  • 9. Evaluation(Model fit stats calculation) • Accuracy • Precision and recall • Squared error • Likelihood • Posterior probability • Cost / Utility • Margin • Entropy • K-L divergence • Etc.
  • 10. Optimization(Methods for Parameters Estimation) • Combinatorial optimization • E.g.: Greedy search • Convex optimization • E.g.: Gradient descent • Constrained optimization • E.g.: Linear programming
  • 11. ML in Practice • Understanding domain, prior knowledge, and goals • Data integration, selection, cleaning, pre- processing, etc. • Learning models • Interpreting results • Consolidating and deploying discovered knowledge • Loop
  • 13. Machine Learning • How did our brain process the images? • How did the grouping happen? • Human brain processed the given images - learning • After learning the brain simply looked at the new image and compared with the groups classified the image to the closest group - Classification • If a machine has to perform the same operation we use Machine Learning • We write programs for learning and then classification, this is nothing but machine learning
  • 15. The machine learning framework • Apply a prediction function to a feature representation of the image to get the desired output: Slide credit: L.
  • 16. The Machine Learning framework y = f(x) output prediction function Image feature • Training: given a training set of labeled examples {(x1,y1), …, (xN,yN)}, estimate the prediction function f by minimizing the prediction error on the training set • Testing: apply f to a never before seen test example x and output the predicted value y = f(x) Methods includes Parametric Methods and Non-parametric Methods
  • 17. Classification: predicting a category Some techniques: - Naïve Bayes - Decision Tree - Logistic Regression - SGD - Support Vector Machines - Neural Network - Ensembles
  • 18. • Decision Trees – rpart, party, tree, chaid • Random Forest – randomForest, party • Neural Networks – nnet, neuralnet, RSNNS • SVM and Kernel estimation – e1071, kernalab •Performance Evaluation - ROCR Etc. Classification in R
  • 19. Highest market share Data handling and analytics capabilities Easy to use/ learn Why R/Python
  • 20. Table of Contents 1) Business Problem 2) Base knowledge 3) Difference between Linear Regression & Logistic Regression 4) Logistic Regression 5) Logistic Model Development 6) Model Validation 7) Hands on – R/Python 8) Quizes 9) Case Solution
  • 22. Business Problem We have data for 900 banking customers, whether an applicant was rated as “Good Credit/Non-Default” or “Bad Credit/Default” based on some given attributes. Analytical Problem: We need to analyze and do exploratory data analysis and build model Here is the Definitions of the columns of the data: ⮚ Age-Age of Applicant ⮚ Education- Range 1-5 ⮚ Employment – Range 0-33 ⮚ Address – Range 0-34 ⮚ Income – Monthly Salary(‘Thousands) ⮚ Debtinc – Debt-to-Income Ratio ⮚ Credit debt – Credit card debt(credit loans) ⮚ Other debts – Any other loan liabilities ⮚ Default – 1(Loan default), 0 (Non-Default) 1. Understanding business problem 2. What is Default/Non-Default 3. Need of predictive model 4. Other problems that can be answered by similar scenario 5. What is Target/Dependent Variable 6. What are independent variables 7. Exploratory Analysis 8. Understanding Logistic Regression
  • 24. Models can be developed in domains of risk, marketing or collections. • Risk: Models to assess the credit worthiness of an application ✓ Credit card & Loans: Bad vs. Good ✓ Fraud Detection: Fraud Vs. Not Fraud • Collections: Models to identify cardholders that are likely to default and thus need collection effort (Payment Projection Models) ✓ Credit card & Loans: Default vs. Non Default • Insurance: Models to identify claims that are Fraud or Not Fraud • Marketing & Sales: Models to identify to responders to promotional campaigns ✓ Marketing: Response Vs. Non Response ✓ Sales: Buying Vs. Not Buying • Operations: Models to identify to employees who attrite ✓ Operations: Attrition Vs. Retention • Website: Models to identify to weather visitor will click or not ✓ Website: Click Vs. Not Click • Gaming: Models to identify to who will win ✓ Gaming: Win Vs. Loss • Health Care: Models to identify to cure or not cure ✓ Health Care: Cure Vs. Not Cure Logistic Regression Modeling Applications
  • 25. Meaning of Modeling By “Modeling” we mean developing set of equations or mathematical formulation by which we can : • Predict certain events • Identify the drivers of certain events based on some explanatory variables For example, we can build models to predict drivers of sales, risk of a borrower. Historical Data Statistical Analyse s Predict Future Events Bad 25 Your Company
  • 26. Recall: Modeling Process 3) Model Development • Multivariate Analysis • Variable Creation • Variable Transformation and Binning • Multicollinearity Check • Variable Selection • Technique Selection Building Blocks of the Modeling Process 2) Data Analysis • Univariate Analysis • Extreme value treatment • Missing Value Treatment • Graphical Representation 1) Data Preparation • Data Extraction • Data Collation • Data Sampling and holdouts 4) Model Validation • Performance Analysis and charting • Multiple model comparison • Out of Sample Validation
  • 27. What ? Regression is formulating a functional relationship between a set of independent or Explanatory variables (Xs) with a Dependent or Response variable (Y). Y=f(X1, X2, X3,…,Xn) Why ? ▪Knowledge of Y is crucial for decision making. ▪ Will he/she buy or not? ▪ Shall I offer him/her the loan or not? ▪X is available at the time of decision making and is related to Y, thus making it possible to have a prediction of Y. Recall: What is Regression?
  • 28. ÐLogistic Regression Continuous Binary (1/0) ÐOrdinary Least Squares Regression Y Sales Volume, Claim Amount, Number of Equipments, % Increase in Growth, etc. Buy/No Buy, Delinquent/Non Delinquent, Growth/No Growth, etc. Recall: Types of Regression
  • 29. Quiz 1 Is Logistic regression mainly used for Regression? True False A B 1. A 2. B
  • 34. Quiz 2 Which of the following methods do we use to best fit the data in Logistic Regression? Least Square Error Maximum Likelihood A B Jaccard distance Both A and B C D 1. A 2. B 3. C 4. D
  • 36. Steps of Modelling Outlier treatment •Box Plot •Percentile(99) Missing value treatment Normalizatio n of data Handling multi- collinearity •Performed VIF Dummy variable creation •Handle categorical variables Logisitc Model • Variable Selection • Optimising Model
  • 37. EDA on banking customer data
  • 39. Outlier Detection: identify abnormal patterns Example: identify engine anomalies Features: - Heat generated - Vibration of engine
  • 40. Outlier Detection Target Function: outlier factor Outlier factor (0…1) Some techniques: - Statistical techniques - Local outlier factor - One-class SVM ID Total$ Age City OF 101 $200 25 SF 0.1 102 $350 35 LA 0.05 103 $25 15 LA 0.2 … … … … 0.1 0.9 0.2 0.15 0.1
  • 41. Quiz 3 Which of the following measures of central tendency will always change if a single value in the data changes? Mean Median A B Mode All C D 1. A 2. B 3. C 4. D
  • 43. Quiz 4 A correlation between age and health of a person found to be -1.09. On basis of this you would tell the doctors that? The age is good predictor of health The age is poor predictor of health A B None of these C 1. A 2. B 3. C
  • 47. Logistic Procedure-Concordance Association of Predicted Probabilities and Observed Responses Percent Concordant 79.0 Percent Discordant 19.1 Percent Tied 1.9 Pairs 3627468 ✓ Concordance is used to assess how well scorecards are separating the good and bad accounts in the development sample. ✓ The higher is the concordance, the larger is the separation of scores between good and bad accounts. ✓ The concordance ratio is a non-negative number, which theoretically may lie between 0 and 1. Concordance Determination: Among all pairs formed from 0 & 1 observations from the dependent variable, the % of pairs where the probability assigned to an observation with value 1 for the dependent variable is greater than that assigned to an observation with value 0. Percentage of concordant pairs should be at least greater than 60.
  • 49. Solution 1. AUC of the model being 87% means that model have been able to distinguish between defaulters and non-defaulters with 37% better than baseline/random model 1. Initial event rate i.e. default rate being 26% which is baseline result while Precision of model being 55%, model have been able to provide 2x better lift.
  • 50. Quiz 5 For the below confusion matrix, what is the recall? 1. 0.7 2. 0.8 3. 0.9 4. 0.95
  • 51. Q & A