Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

plotbins

Plot histogram counts for predictor variables

Syntax

plotbins(sc,PredictorName)
hFigure = plotbins(sc,PredictorName)
hFigure = plotbins(___,Name,Value)

Description

example

plotbins(sc,PredictorName) plots histogram counts for given predictor variables. When a predictor’s bins are modified using modifybins or autobinning, rerun plotbins to update the figure to reflect the change.

example

hFigure = plotbins(sc,PredictorName) returns a handle to the figure. plotbins plots histogram counts for given predictor variables. When a predictor’s bins are modified using modifybins or autobinning, rerun plotbins to update the figure to reflect the change.

example

hFigure = plotbins(___,Name,Value) returns a handle to the figure. plotbins plots histogram counts for given predictor variables using optional name-value pair arguments. When a predictor’s bins are modified using modifybins or autobinning, rerun plotbins to update the figure to reflect the change.

Examples

collapse all

Create a creditscorecard object using the CreditCardData.mat file to load the data (using a dataset from Refaat 2011).

load CreditCardData 
sc = creditscorecard(data);

Perform automatic binning for the PredictorName input argument for CustIncome using the defaults for the algorithm Monotone.

sc = autobinning(sc, 'CustIncome')
sc = 
  creditscorecard with properties:

                GoodLabel: 0
              ResponseVar: 'status'
               WeightsVar: ''
                 VarNames: {1x11 cell}
        NumericPredictors: {1x7 cell}
    CategoricalPredictors: {'ResStatus'  'EmpStatus'  'OtherCC'}
                    IDVar: ''
            PredictorVars: {1x10 cell}
                     Data: [1200x11 table]

Use bininfo to display the autobinned data.

[bi, cp] = bininfo(sc, 'CustIncome')
bi=8x6 table
          Bin          Good    Bad     Odds         WOE       InfoValue 
    _______________    ____    ___    _______    _________    __________

    '[-Inf,29000)'      53      58    0.91379     -0.79457       0.06364
    '[29000,33000)'     74      49     1.5102     -0.29217     0.0091366
    '[33000,35000)'     68      36     1.8889     -0.06843    0.00041042
    '[35000,40000)'    193      98     1.9694    -0.026696    0.00017359
    '[40000,42000)'     68      34          2    -0.011271    1.0819e-05
    '[42000,47000)'    164      66     2.4848      0.20579     0.0078175
    '[47000,Inf]'      183      56     3.2679      0.47972      0.041657
    'Totals'           803     397     2.0227          NaN       0.12285

cp = 

       29000
       33000
       35000
       40000
       42000
       47000

Manually remove the second cut point (the boundary between the second and third bins) to merge bins two and three. Use the modifybins function to update the scorecard and then display updated bin information.

cp(2) = [];
sc = modifybins(sc,'CustIncome','CutPoints',cp);
bi = bininfo(sc,'CustIncome')
bi=7x6 table
          Bin          Good    Bad     Odds         WOE       InfoValue 
    _______________    ____    ___    _______    _________    __________

    '[-Inf,29000)'      53      58    0.91379     -0.79457       0.06364
    '[29000,35000)'    142      85     1.6706     -0.19124     0.0071274
    '[35000,40000)'    193      98     1.9694    -0.026696    0.00017359
    '[40000,42000)'     68      34          2    -0.011271    1.0819e-05
    '[42000,47000)'    164      66     2.4848      0.20579     0.0078175
    '[47000,Inf]'      183      56     3.2679      0.47972      0.041657
    'Totals'           803     397     2.0227          NaN       0.12043

Plot the histogram count for updated bin information for the PredictorName called CustIncome.

plotbins(sc,'CustIncome');

Create a creditscorecard object using the CreditCardData.mat file to load the data (using a dataset from Refaat 2011).

load CreditCardData 
sc = creditscorecard(data);

Perform automatic binning for the PredictorName input argument for CustIncome using the defaults for the algorithm Monotone.

sc = autobinning(sc, 'CustIncome')
sc = 
  creditscorecard with properties:

                GoodLabel: 0
              ResponseVar: 'status'
               WeightsVar: ''
                 VarNames: {1x11 cell}
        NumericPredictors: {1x7 cell}
    CategoricalPredictors: {'ResStatus'  'EmpStatus'  'OtherCC'}
                    IDVar: ''
            PredictorVars: {1x10 cell}
                     Data: [1200x11 table]

Use bininfo to display the autobinned data.

[bi, cp] = bininfo(sc, 'CustIncome')
bi=8x6 table
          Bin          Good    Bad     Odds         WOE       InfoValue 
    _______________    ____    ___    _______    _________    __________

    '[-Inf,29000)'      53      58    0.91379     -0.79457       0.06364
    '[29000,33000)'     74      49     1.5102     -0.29217     0.0091366
    '[33000,35000)'     68      36     1.8889     -0.06843    0.00041042
    '[35000,40000)'    193      98     1.9694    -0.026696    0.00017359
    '[40000,42000)'     68      34          2    -0.011271    1.0819e-05
    '[42000,47000)'    164      66     2.4848      0.20579     0.0078175
    '[47000,Inf]'      183      56     3.2679      0.47972      0.041657
    'Totals'           803     397     2.0227          NaN       0.12285

cp = 

       29000
       33000
       35000
       40000
       42000
       47000

Plot the bin information for CustIncome without the Weight of Evidence (WOE) line and without a legend by setting the 'WOE' and 'Legend' name-value arguments to 'Off'. Also, set the 'BinText' name-value pair argument to 'PercentRows' to show as text over the plot bars for the proportion of "Good" and "Bad" within each bin, that is, the probability of "Good" and "Bad" within each bin.

plotbins(sc,'CustIncome','WOE','Off','Legend','Off','BinText','PercentRows');

Input Arguments

collapse all

Credit scorecard model, specified as a creditscorecard object. Use creditscorecard to create a creditscorecard object.

Name of one or more predictors to plot, specified using a character vector or cell array of character vectors containing one or more names of the predictors.

Data Types: char | cell

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: plotbins(sc,PredictorName,'BinText','Count','WOE','On')

collapse all

Information to display on top of plotted bin counts, specified using a character vector with values:

  • None — No text is displayed on top of the bins.

  • Count — For each bin, displays the count for “Good” and “Bad.”

  • PercentRows — For each bin, displays the count for “Good” and “Bad” as a percentage of the number of observations in the bin.

  • PercentCols — For each bin, displays the count for “Good” and “Bad” as a percentage of the total “Good” and total “Bad” in the entire sample.

  • PercentTotal — For each bin, displays the count for “Good” and “Bad” as a percentage of the total number of observations in the entire sample.

Data Types: char

Indicator for Weight of Evidence (WOE) line, specified using a character vector with values On or Off. When set to On, the WOE line is plotted on top of the histogram.

Data Types: char

Indicator for legend on the plot, specified using a character vector with values On or Off.

Data Types: char

Output Arguments

collapse all

Figure handle for histogram plot for predictor variables, returned as figure object or array of figure objects if more than one PredictorName is specified as an input.

References

[1] Anderson, R. The Credit Scoring Toolkit. Oxford University Press, 2007.

[2] Refaat, M. Credit Risk Scorecards: Development and Implementation Using SAS. lulu.com, 2011.

Introduced in R2014b

Was this topic helpful?