SlideShare a Scribd company logo
1 of 11
Download to read offline
Logistic Ordinal Regression
Wendy C Wong

Michal K and Nidhi M
Table of Content
• Ordinal Regression

• Building Linear Models Ordinal Regression

• Linear Models used;

• model parameters updates;

• model predictions

• H2O implementations

• Example and results
What is Ordinal Regression?
• Ordinal regression/classification or ranking learning is a
regression analysis used to predict an ordinal variable (a
variable where the relative ordering between different
values is significant);

• Ordinal regression are used most often in social sciences
to model human levels of preference/satisfaction (levels
1-5 for very poor, poor, average, good, excellent)
Linear Models used for Ordinal Regression
• Let be our predictor of size p and be the associated
ordinal response. Note: takes value from 1 to K.

• A GLM is used to fit ONE coefficient vector for all classes of
the ordinal variable response and a set of thresholds to a data
set.

• model the CUMULATIVE PROBABILITY as the logistic function 

• Note that the separating hyperplanes are parallel for all
classes. The non-decreasing vector is
used to separate all the classes.

• Ordered Probit-standard normal distribution and Proportional
Hazards:
xi
1 + exp(−exp(βT
xi + θj))
yj
θ1 < θ2 < . . . < θK−1
P(y < = j |xi) = σ(βT
xi + θj) = 1/(1 + exp(−βT
xi − θj)) = γij
yi
Model Parameters Updates
• The likelihood function:

• The log-likelihood function is 

• The pdfs are:

• for j = 1

• for j = K 

• To find the model parameters, maximize the log-likelihood
function minus your favorite regularization penalties. Take
the derivatives and update each model parameter with a
learning rate*the derivative for that model parameter…..
N−1
∏
i=0
pd f (yi = yrespi)
N−1
∑
n=0
log(σ(βT
xi + θyj
) − σ(βT
xi + θyj−1))
pd f (yi = 1) = σ(βT
xi + θ1)
pd f (yi = K ) = 1 − pd f (yi = K − 1)
Model Predictions
• The log proportional odds is:

• When the proportional odds > 1 (log(.) > 0), it implies that
it is more probable that the data point belongs to class
j or lower than belonging to classes j+1 and beyond.

• This implies that a data point is classified as:

• class K:

• class j (>=1 and <= K-1): and
log(
γij
1 − γij
) =
1
1 + exp(−βT xi − θj)
1 −
1
1 + exp(−βT xi − θj))
= βT
xi + θj
xi
xi
βT
xi + θK−1 > 0
βT
xi + θj > 0 βT
xi + θj+1 < = 0
Alternate Model Parameters Optimization
• I decided to modify the model parameters to directly
increase the probability of correct predictions. 

• Hence, I will optimize the error function
where

• for correct prediction 

• for incorrect prediction
L(β, θ, xi, yrespi) = (βT
xi + θj)2
N−1
∑
i=0
L(β, θ, xi, yrespi)
L(β, θ, xi, yrespi) = 0
βT
xi + θj < = 0
j < yrespiβT
xi + θj > 0
j > = yrespi
βT
xi + θj > 0
j < yrespi
βT
xi + θj < = 0
j > = yrespi
H2O Implementation
• To use ordinal regression, set family=“ordinal”;

• To change model parameters using the likelihood function, do not set solver or
set solver to “GRADIENT_DESCENT_LH”

• To change model parameters using the other loss function, set solver to
“GRADIENT_DESCENT_SQERR”

• Gradient descent: first-order method, use gridsearch to find good learning rate,
regularization values (beta, alpha)….

• In R: ordinal.fit <- h2o.glm(y=Y, x=X, training_frame=
Dtrain, family="ordinal",
solver="GRADIENT_DESCENT_SQERR")
• In Python:
ordinal_fit = H2OGeneralizedLinearEstimator(family="ordinal",
solver=“GRADIENT_DESCENT_LH”)

ordinal_fit.train(y=Y, x=X, training_frame=Dtrain)
Summary/Results
Table 1
Dataset LH
performance
SQERR
performance
R ordinal
5 columns with enum 0.9959 0.99751
5 numerical columns 0.99968 0.999445
10 columns with enum 0.999405 0.99919
10 numerical columns 0.99507 0.99305
15 columns with enum 0.996385 0.99802
15 numerical columns 0.99938 0.99912
20 columns with enums 0.998 0.999155
20 numerical columns 0.995895 0.99735
50 numerical columns 0.9893 0.9953
Multinomial dataset 0.47372 0.45527
nidhi dataset 0.5675 0.58 0.5775
Reference
• Peter McCullagh, Regression Models for Ordinal Data, J.
R. Statist, Soc. B(1980), 42, No 2, pp.109-142

• Wikipedia, Ordinal Regression

• Alan Agresti, “Analysis of Ordinal Categorical data”, John
Wiley & Sons, Inc. July, 2012

More Related Content

Similar to Logistic Ordinal Regression

08-Regression.pptx
08-Regression.pptx08-Regression.pptx
08-Regression.pptx
Shree Shree
 
ICML2017 best paper (Understanding black box predictions via influence functi...
ICML2017 best paper (Understanding black box predictions via influence functi...ICML2017 best paper (Understanding black box predictions via influence functi...
ICML2017 best paper (Understanding black box predictions via influence functi...
Antosny
 

Similar to Logistic Ordinal Regression (20)

L1 intro2 supervised_learning
L1 intro2 supervised_learningL1 intro2 supervised_learning
L1 intro2 supervised_learning
 
General Tips for participating Kaggle Competitions
General Tips for participating Kaggle CompetitionsGeneral Tips for participating Kaggle Competitions
General Tips for participating Kaggle Competitions
 
Gradient Boosted Regression Trees in scikit-learn
Gradient Boosted Regression Trees in scikit-learnGradient Boosted Regression Trees in scikit-learn
Gradient Boosted Regression Trees in scikit-learn
 
ngboost.pptx
ngboost.pptxngboost.pptx
ngboost.pptx
 
ngboost.pptx
ngboost.pptxngboost.pptx
ngboost.pptx
 
variBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pdf
variBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pdfvariBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pdf
variBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pdf
 
eviewsOLSMLE
eviewsOLSMLEeviewsOLSMLE
eviewsOLSMLE
 
Calculus Review Session Brian Prest Duke University Nicholas School of the En...
Calculus Review Session Brian Prest Duke University Nicholas School of the En...Calculus Review Session Brian Prest Duke University Nicholas School of the En...
Calculus Review Session Brian Prest Duke University Nicholas School of the En...
 
variBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pptx
variBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pptxvariBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pptx
variBAD, A Very Good Method for Bayes-Adaptive Deep RL via Meta-Learning.pptx
 
Lecture 5 - Gradient Descent, a lecture in subject module Statistical & Machi...
Lecture 5 - Gradient Descent, a lecture in subject module Statistical & Machi...Lecture 5 - Gradient Descent, a lecture in subject module Statistical & Machi...
Lecture 5 - Gradient Descent, a lecture in subject module Statistical & Machi...
 
Linear Regression.pptx
Linear Regression.pptxLinear Regression.pptx
Linear Regression.pptx
 
Sparsenet
SparsenetSparsenet
Sparsenet
 
Paper Study: Melding the data decision pipeline
Paper Study: Melding the data decision pipelinePaper Study: Melding the data decision pipeline
Paper Study: Melding the data decision pipeline
 
Demystifying deep reinforement learning
Demystifying deep reinforement learningDemystifying deep reinforement learning
Demystifying deep reinforement learning
 
Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models
 
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
Gradient Boosted Regression Trees in Scikit Learn by Gilles Louppe & Peter Pr...
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
 
08-Regression.pptx
08-Regression.pptx08-Regression.pptx
08-Regression.pptx
 
ICML2017 best paper (Understanding black box predictions via influence functi...
ICML2017 best paper (Understanding black box predictions via influence functi...ICML2017 best paper (Understanding black box predictions via influence functi...
ICML2017 best paper (Understanding black box predictions via influence functi...
 
Lec7 deeprlbootcamp-svg+scg
Lec7 deeprlbootcamp-svg+scgLec7 deeprlbootcamp-svg+scg
Lec7 deeprlbootcamp-svg+scg
 

More from Sri Ambati

More from Sri Ambati (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Generative AI Masterclass - Model Risk Management.pptx
Generative AI Masterclass - Model Risk Management.pptxGenerative AI Masterclass - Model Risk Management.pptx
Generative AI Masterclass - Model Risk Management.pptx
 
AI and the Future of Software Development: A Sneak Peek
AI and the Future of Software Development: A Sneak Peek AI and the Future of Software Development: A Sneak Peek
AI and the Future of Software Development: A Sneak Peek
 
LLMOps: Match report from the top of the 5th
LLMOps: Match report from the top of the 5thLLMOps: Match report from the top of the 5th
LLMOps: Match report from the top of the 5th
 
Building, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for ProductionBuilding, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for Production
 
Building LLM Solutions using Open Source and Closed Source Solutions in Coher...
Building LLM Solutions using Open Source and Closed Source Solutions in Coher...Building LLM Solutions using Open Source and Closed Source Solutions in Coher...
Building LLM Solutions using Open Source and Closed Source Solutions in Coher...
 
Risk Management for LLMs
Risk Management for LLMsRisk Management for LLMs
Risk Management for LLMs
 
Open-Source AI: Community is the Way
Open-Source AI: Community is the WayOpen-Source AI: Community is the Way
Open-Source AI: Community is the Way
 
Building Custom GenAI Apps at H2O
Building Custom GenAI Apps at H2OBuilding Custom GenAI Apps at H2O
Building Custom GenAI Apps at H2O
 
Applied Gen AI for the Finance Vertical
Applied Gen AI for the Finance Vertical Applied Gen AI for the Finance Vertical
Applied Gen AI for the Finance Vertical
 
Cutting Edge Tricks from LLM Papers
Cutting Edge Tricks from LLM PapersCutting Edge Tricks from LLM Papers
Cutting Edge Tricks from LLM Papers
 
Practitioner's Guide to LLMs: Exploring Use Cases and a Glimpse Beyond Curren...
Practitioner's Guide to LLMs: Exploring Use Cases and a Glimpse Beyond Curren...Practitioner's Guide to LLMs: Exploring Use Cases and a Glimpse Beyond Curren...
Practitioner's Guide to LLMs: Exploring Use Cases and a Glimpse Beyond Curren...
 
Open Source h2oGPT with Retrieval Augmented Generation (RAG), Web Search, and...
Open Source h2oGPT with Retrieval Augmented Generation (RAG), Web Search, and...Open Source h2oGPT with Retrieval Augmented Generation (RAG), Web Search, and...
Open Source h2oGPT with Retrieval Augmented Generation (RAG), Web Search, and...
 
KGM Mastering Classification and Regression with LLMs: Insights from Kaggle C...
KGM Mastering Classification and Regression with LLMs: Insights from Kaggle C...KGM Mastering Classification and Regression with LLMs: Insights from Kaggle C...
KGM Mastering Classification and Regression with LLMs: Insights from Kaggle C...
 
LLM Interpretability
LLM Interpretability LLM Interpretability
LLM Interpretability
 
Never Reply to an Email Again
Never Reply to an Email AgainNever Reply to an Email Again
Never Reply to an Email Again
 
Introducción al Aprendizaje Automatico con H2O-3 (1)
Introducción al Aprendizaje Automatico con H2O-3 (1)Introducción al Aprendizaje Automatico con H2O-3 (1)
Introducción al Aprendizaje Automatico con H2O-3 (1)
 
From Rapid Prototypes to an end-to-end Model Deployment: an AI Hedge Fund Use...
From Rapid Prototypes to an end-to-end Model Deployment: an AI Hedge Fund Use...From Rapid Prototypes to an end-to-end Model Deployment: an AI Hedge Fund Use...
From Rapid Prototypes to an end-to-end Model Deployment: an AI Hedge Fund Use...
 
AI Foundations Course Module 1 - Shifting to the Next Step in Your AI Transfo...
AI Foundations Course Module 1 - Shifting to the Next Step in Your AI Transfo...AI Foundations Course Module 1 - Shifting to the Next Step in Your AI Transfo...
AI Foundations Course Module 1 - Shifting to the Next Step in Your AI Transfo...
 
AI Foundations Course Module 1 - An AI Transformation Journey
AI Foundations Course Module 1 - An AI Transformation JourneyAI Foundations Course Module 1 - An AI Transformation Journey
AI Foundations Course Module 1 - An AI Transformation Journey
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 

Logistic Ordinal Regression

  • 1. Logistic Ordinal Regression Wendy C Wong Michal K and Nidhi M
  • 2. Table of Content • Ordinal Regression • Building Linear Models Ordinal Regression • Linear Models used; • model parameters updates; • model predictions • H2O implementations • Example and results
  • 3. What is Ordinal Regression? • Ordinal regression/classification or ranking learning is a regression analysis used to predict an ordinal variable (a variable where the relative ordering between different values is significant); • Ordinal regression are used most often in social sciences to model human levels of preference/satisfaction (levels 1-5 for very poor, poor, average, good, excellent)
  • 4. Linear Models used for Ordinal Regression • Let be our predictor of size p and be the associated ordinal response. Note: takes value from 1 to K. • A GLM is used to fit ONE coefficient vector for all classes of the ordinal variable response and a set of thresholds to a data set. • model the CUMULATIVE PROBABILITY as the logistic function • Note that the separating hyperplanes are parallel for all classes. The non-decreasing vector is used to separate all the classes. • Ordered Probit-standard normal distribution and Proportional Hazards: xi 1 + exp(−exp(βT xi + θj)) yj θ1 < θ2 < . . . < θK−1 P(y < = j |xi) = σ(βT xi + θj) = 1/(1 + exp(−βT xi − θj)) = γij yi
  • 5.
  • 6. Model Parameters Updates • The likelihood function: • The log-likelihood function is • The pdfs are: • for j = 1 • for j = K • To find the model parameters, maximize the log-likelihood function minus your favorite regularization penalties. Take the derivatives and update each model parameter with a learning rate*the derivative for that model parameter….. N−1 ∏ i=0 pd f (yi = yrespi) N−1 ∑ n=0 log(σ(βT xi + θyj ) − σ(βT xi + θyj−1)) pd f (yi = 1) = σ(βT xi + θ1) pd f (yi = K ) = 1 − pd f (yi = K − 1)
  • 7. Model Predictions • The log proportional odds is: • When the proportional odds > 1 (log(.) > 0), it implies that it is more probable that the data point belongs to class j or lower than belonging to classes j+1 and beyond. • This implies that a data point is classified as: • class K: • class j (>=1 and <= K-1): and log( γij 1 − γij ) = 1 1 + exp(−βT xi − θj) 1 − 1 1 + exp(−βT xi − θj)) = βT xi + θj xi xi βT xi + θK−1 > 0 βT xi + θj > 0 βT xi + θj+1 < = 0
  • 8. Alternate Model Parameters Optimization • I decided to modify the model parameters to directly increase the probability of correct predictions. • Hence, I will optimize the error function where • for correct prediction • for incorrect prediction L(β, θ, xi, yrespi) = (βT xi + θj)2 N−1 ∑ i=0 L(β, θ, xi, yrespi) L(β, θ, xi, yrespi) = 0 βT xi + θj < = 0 j < yrespiβT xi + θj > 0 j > = yrespi βT xi + θj > 0 j < yrespi βT xi + θj < = 0 j > = yrespi
  • 9. H2O Implementation • To use ordinal regression, set family=“ordinal”; • To change model parameters using the likelihood function, do not set solver or set solver to “GRADIENT_DESCENT_LH” • To change model parameters using the other loss function, set solver to “GRADIENT_DESCENT_SQERR” • Gradient descent: first-order method, use gridsearch to find good learning rate, regularization values (beta, alpha)…. • In R: ordinal.fit <- h2o.glm(y=Y, x=X, training_frame= Dtrain, family="ordinal", solver="GRADIENT_DESCENT_SQERR") • In Python: ordinal_fit = H2OGeneralizedLinearEstimator(family="ordinal", solver=“GRADIENT_DESCENT_LH”) ordinal_fit.train(y=Y, x=X, training_frame=Dtrain)
  • 10. Summary/Results Table 1 Dataset LH performance SQERR performance R ordinal 5 columns with enum 0.9959 0.99751 5 numerical columns 0.99968 0.999445 10 columns with enum 0.999405 0.99919 10 numerical columns 0.99507 0.99305 15 columns with enum 0.996385 0.99802 15 numerical columns 0.99938 0.99912 20 columns with enums 0.998 0.999155 20 numerical columns 0.995895 0.99735 50 numerical columns 0.9893 0.9953 Multinomial dataset 0.47372 0.45527 nidhi dataset 0.5675 0.58 0.5775
  • 11. Reference • Peter McCullagh, Regression Models for Ordinal Data, J. R. Statist, Soc. B(1980), 42, No 2, pp.109-142 • Wikipedia, Ordinal Regression • Alan Agresti, “Analysis of Ordinal Categorical data”, John Wiley & Sons, Inc. July, 2012