What is a decision tree?

Credit Risk Modeling in R

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

Decision tree example

Screen Shot 2020-06-22 at 2.56.34 PM.png

Credit Risk Modeling in R

How to make splitting decision?

Screen Shot 2020-06-22 at 2.57.01 PM.png

Credit Risk Modeling in R

How to make splitting decision?

Screen Shot 2020-06-22 at 2.57.13 PM.png

Credit Risk Modeling in R

Example

Screen Shot 2020-06-22 at 2.59.56 PM.png

Credit Risk Modeling in R

Example

Screen Shot 2020-06-22 at 3.00.08 PM.png

  • Actual non-defaults in this node using this split
Credit Risk Modeling in R

Example

Screen Shot 2020-06-22 at 3.00.20 PM.png

  • Actual defaults in this node using this split
Credit Risk Modeling in R

Example

Screen Shot 2020-06-22 at 2.59.25 PM.png

Ideal scenario

Credit Risk Modeling in R

Example

Screen Shot 2020-06-22 at 3.00.48 PM.png

Gini = 2*prop(default)*prop(non-default)

Gini_R = 2*(250/500)*(250/500) = 0.5

Gini_N2 = 2*(80/230)*(150/230) = 0.4536

Gini_N1 = 2*(170/270)*(100/270) = 0.4664

Credit Risk Modeling in R

Example

Screen Shot 2020-06-22 at 3.00.48 PM.png

Gain

= Gini_R-prop(cases in N1)*Gini_N1 - prop(cases in N2) * Gini_N2

= 0.5 - 270/500 * 0.4664 - 230/500 * 0.4536

= 0.039488

  • Maximum gain
Credit Risk Modeling in R

Let's practice!

Credit Risk Modeling in R

Preparing Video For Download...