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.

creditscorecard

Create creditscorecard object to build credit scorecard model

Description

Build a credit scorecard model by creating a creditscorecard object and specify input data in a table format.

After creating a creditscorecard object, you can use the associated object functions to bin the data and perform logistic regression analysis to develop a credit scorecard model to guide credit decisions. This workflow shows how to develop a credit scorecard model.

  1. Create a creditscorecard object (see Create creditscorecard and Properties).

  2. Bin the data.

  3. Fit a logistic regression model.

  4. Review and format the credit scorecard points.

  5. Score the data.

  6. Calculate the probabilities of default for the data.

  7. Validate the quality of the credit scorecard model.

For more detailed information on this workflow, see Credit Scorecard Modeling Workflow.

Creation

Syntax

sc = creditscorecard(data)
sc = creditscorecard(___,Name,Value)

Description

example

sc = creditscorecard(data) creates a creditscorecard object by specifying data. The credit scorecard model, returned as a creditscorecard object, contains the binning maps or rules (cut points or category groupings) for one or more predictors.

example

sc = creditscorecard(___,Name,Value) sets Properties using name-value pairs and any of the arguments in the previous syntax. For example, sc = creditscorecard(data,'GoodLabel',0,'IDVar','CustID','ResponseVar','status','PredictorVars',{'CustID','CustIncome'}). You can specify multiple name-value pairs.

Note

To use observation (sample) weights in the credit scorecard workflow, when creating a creditscorecard object, you must use the optional name-value pair WeightsVar to define which column in the data contains the weights.

Input Arguments

expand all

Data for the creditscorecard object, specified as a MATLAB® table, where each column of data can be any one of the following data types:

  • Numeric

  • Logical

  • Cell array of character vectors

  • Character array

  • Categorical

  • String

In addition, the table must contain a binary response variable. Before creating a creditscorecard object, perform a data preparation task to have appropriately structured data as input to a creditscorecard object. The data input sets the Data property.

Data Types: table

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: sc = creditscorecard(data,'GoodLabel',0,'IDVar','CustID','ResponseVar','status','PredictorVars',{'CustID','CustIncome'})

expand all

Indicator for which of the two possible values in the response variable correspond to “Good” observations, specified as a numeric scalar, logical, or character vector. The GoodLabel name-value pair argument sets the GoodLabel property.

When specifying GoodLabel, follow these guidelines.

If Response Is...GoodLabel Must be...
numericnumeric
logicallogical or numeric
cell array of character vectorscharacter vector
character arraycharacter vector
categoricalcharacter vector

If not specified, GoodLabel is set to the response value with the highest count. However, if the optional WeightsVar argument is provided when creating the creditscorecard object, then counts are replaced with weighted frequencies. For more information, see Credit Scorecard Modeling Using Observation Weights.

GoodLabel can only be set when creating the creditscorecard object. This parameter cannot be set using dot notation.

Data Types: char | double

Variable name used as ID or tag for the observations, specified as a character vector. The IDVar data could be an ordinal number (for example, 1,2,3...), a Social Security number. This is provided as a convenience to remove this column from the predictor variables. IDVar is case-sensitive. The IDVar name-value pair argument sets the IDVar property.

You can set this optional parameter using the creditscorecard function or by using dot notation at the command line, as follows.

Example: sc.IDVar = 'CustID'

Data Types: char

Response variable name for the “Good” or “Bad” indicator, specified as a character vector. The response variable data must be binary. The ResponseVar name-value pair argument sets the ResponseVar property.

If not specified, ResponseVar is set to the last column of the data input. ResponseVar can only be set when creating the creditscorecard object using the creditscorecard function. ResponseVar is case-sensitive.

Data Types: char

Weights variable name, specified as a character vector to indicate which column name in the data table contains the row weights. WeightsVar is case-sensitive. The WeightsVar name-value pair argument sets the WeightsVar property, and this property can only be set at the creation of a creditscorecard object. If the name-value pair argument WeightsVar is not specified when creating a creditscorecard object, then observation weights are set to unit weights by default.

The WeightsVar values are used in the credit scorecard workflow by autobinning, bininfo, fitmodel, and validatemodel. For more information, see Credit Scorecard Modeling Using Observation Weights.

Data Types: char

Predictor variable names, specified using a cell array of character vectors containing names. By default, when you create a credit scorecard creditscorecard, all variables are predictors except for IDVar and ResponseVar.

The PredictorVars name-value pair argument sets the PredictorVars property.This property can be modified by using dot notation or by using a name-value pair argument for the fitmodel function. PredictorVars is case-sensitive and the predictor variable name cannot be the same as the IDVar or ResponseVar.

Data Types: cell

Properties

expand all

Data used to create the creditscorecard object, specified as a table when creating a creditscorecard object. In the Data property, categorical predictors are stored as categorical arrays.

Example: sc.Data(1:10,:)

Data Types: table

Name of the variable used as ID or tag for the observations, specified as a character vector. This property can be set as an optional parameter when creating a creditscorecard object or by using dot notation at the command line. IDVar is case-sensitive.

Example: sc.IDVar = 'CustID'

Data Types: char

This property is read-only.

VarNames is a cell array of character vectors containing the names of all variables in the data. The VarNames come directly from the data input to the creditscorecard object. VarNames is case-sensitive.

Data Types: cell

Name of the response variable, “Good” or “Bad” indicator, specified as a character vector. The response variable data must be binary. If not specified, ResponseVar is set to the last column of the data input. This property can only be set with an optional parameter when creating a creditscorecard object. ResponseVar is case-sensitive.

Data Types: char

Name of the variable used as ID or tag to indicate which column name in the data table contains the row weights, specified as a character vector. This property can be set as an optional parameter (WeightsVar) when creating a creditscorecard object. WeightsVar is case-sensitive.

Data Types: char

Indicator for which of the two possible values in the response variable correspond to “Good” observations. When specifying GoodLabel, follow these guidelines:

If Response is...GoodLabel must be:
numericnumeric
logicallogical or numeric
cell array of character vectorscharacter vector
character arraycharacter vector
categoricalcharacter vector

If not specified, GoodLabel is set to the response value with the highest count. This property can only be set with an optional parameter when creating a creditscorecard object. This property cannot be set using dot notation.

Data Types: char | double

Predictor variable names, specified using a cell array of character vectors containing names. By default, when you create a creditscorecard object, all variables are predictors except for IDVar and ResponseVar. This property can be modified using a name-value pair argument for the fitmodel function or by using dot notation. PredictorVars is case-sensitive and the predictor variable name cannot be the same as the IDVar or ResponseVar.

Example: sc.PredictorVars = {'CustID','CustIncome'}

Data Types: cell

Name of numeric predictors, specified as a character vector. This property cannot be set by using dot notation at the command line. It can only be modified using the modifypredictor function.

Data Types: char

Name of categorical predictors, specified as a character vector. This property cannot be set by using dot notation at the command line. It can only be modified using the modifypredictor function.

Data Types: char

creditscorecard PropertySet/Modify Property from Command Line Using creditscorecard FunctionModify Property Using Dot NotationProperty Not User-Defined and Value Is Defined Internally
DataNoNoYes, copy of data input
IDVarYesYesNo, but the user specifies this
VarNamesNoNoYes
ResponseVarYesNoIf not specified, set to last column of data input
WeightsVarNoNoYes
GoodLabelYesNoIf not specified, set to response value with highest count
PredictorVarsYes (also modifiable using fitmodel function)YesYes, but the user can modify this
NumericPredictorsNo (can only be modified using modifypredictor function)NoYes, but the user can modify this
CategoricalPredictorsNo (can only be modified using modifypredictor function)NoYes, but the user can modify this

Object Functions

autobinningPerform automatic binning of given predictors
bininfoReturn predictor’s bin information
predictorinfoSummary of credit scorecard predictor properties
modifypredictorSet properties of credit scorecard predictors
modifybinsModify predictor’s bins
bindataBinned predictor variables
plotbinsPlot histogram counts for predictor variables
fitmodelFit logistic regression model to Weight of Evidence (WOE) data
setmodelSet model predictors and coefficients
displaypointsReturn points per predictor per bin
formatpointsFormat scorecard points and scaling
scoreCompute credit scores for given data
probdefaultLikelihood of default for given data set
validatemodelValidate quality of credit scorecard model

Examples

expand 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)
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 the CreditCardData.mat file to load the data (dataWeights) that contains a column (RowWeights) for the weights (using a dataset from Refaat 2011).

load CreditCardData

Create a creditscorecard object using the optional name-value pair argument for 'WeightsVar'.

sc = creditscorecard(dataWeights,'WeightsVar','RowWeights')
sc = 

  creditscorecard with properties:

                GoodLabel: 0
              ResponseVar: 'status'
                 VarNames: {1×12 cell}
        NumericPredictors: {1×7 cell}
    CategoricalPredictors: {'ResStatus'  'EmpStatus'  'OtherCC'}
                    IDVar: ''
            PredictorVars: {1×10 cell}
               WeightsVar: 'RowWeights'
                     Data: [1200×12 table]

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

load CreditCardData 
sc = creditscorecard(data)
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]

To display the creditscorecard object properties, use dot notation.

sc.PredictorVars
ans = 1x10 cell array
  Columns 1 through 4

    {'CustID'}    {'CustAge'}    {'TmAtAddress'}    {'ResStatus'}

  Columns 5 through 8

    {'EmpStatus'}    {'CustIncome'}    {'TmWBank'}    {'OtherCC'}

  Columns 9 through 10

    {'AMBalance'}    {'UtilRate'}

sc.VarNames
ans = 1x11 cell array
  Columns 1 through 4

    {'CustID'}    {'CustAge'}    {'TmAtAddress'}    {'ResStatus'}

  Columns 5 through 8

    {'EmpStatus'}    {'CustIncome'}    {'TmWBank'}    {'OtherCC'}

  Columns 9 through 11

    {'AMBalance'}    {'UtilRate'}    {'status'}

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

load CreditCardData 
sc = creditscorecard(data)
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]

Since the IDVar property has public access, you can change its value at the command line.

sc.IDVar = 'CustID'
sc = 
  creditscorecard with properties:

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

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

load CreditCardData 
sc = creditscorecard(data)
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]

In this example, the default values for the properties ResponseVar, PredictorVars and GoodLabel are assigned when this object is created. By default, the property ResponseVar is set to the variable name that is in the last column of the input data ('status' in this example). The property PredictorVars contains the names of all the variables that are in VarNames, but excludes IDVar and ResponseVar. Also, by default in the previous example, GoodLabel is set to 0, since it is the value in the response variable (ResponseVar) with the highest count.

Display the creditscorecard object properties using dot notation.

sc.PredictorVars
ans = 1x10 cell array
  Columns 1 through 4

    {'CustID'}    {'CustAge'}    {'TmAtAddress'}    {'ResStatus'}

  Columns 5 through 8

    {'EmpStatus'}    {'CustIncome'}    {'TmWBank'}    {'OtherCC'}

  Columns 9 through 10

    {'AMBalance'}    {'UtilRate'}

sc.VarNames
ans = 1x11 cell array
  Columns 1 through 4

    {'CustID'}    {'CustAge'}    {'TmAtAddress'}    {'ResStatus'}

  Columns 5 through 8

    {'EmpStatus'}    {'CustIncome'}    {'TmWBank'}    {'OtherCC'}

  Columns 9 through 11

    {'AMBalance'}    {'UtilRate'}    {'status'}

Since IDVar and PredictorVars have public access, you can change their values at the command line.

sc.IDVar = 'CustID'
sc = 
  creditscorecard with properties:

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

sc.PredictorVars = {'CustIncome','ResStatus','AMBalance'}
sc = 
  creditscorecard with properties:

                GoodLabel: 0
              ResponseVar: 'status'
               WeightsVar: ''
                 VarNames: {1x11 cell}
        NumericPredictors: {'CustIncome'  'AMBalance'}
    CategoricalPredictors: {'ResStatus'}
                    IDVar: 'CustID'
            PredictorVars: {'CustIncome'  'ResStatus'  'AMBalance'}
                     Data: [1200x11 table]

disp(sc)
  creditscorecard with properties:

                GoodLabel: 0
              ResponseVar: 'status'
               WeightsVar: ''
                 VarNames: {1x11 cell}
        NumericPredictors: {'CustIncome'  'AMBalance'}
    CategoricalPredictors: {'ResStatus'}
                    IDVar: 'CustID'
            PredictorVars: {'CustIncome'  'ResStatus'  'AMBalance'}
                     Data: [1200x11 table]

Create a creditscorecard object using the CreditCardData.mat file to load the data (using a dataset from Refaat 2011). Then use name-value pair arguments for creditscorecard to define GoodLabel and ResponseVar.

load CreditCardData 
sc = creditscorecard(data,'IDVar','CustID','GoodLabel',0,'ResponseVar','status')
sc = 
  creditscorecard with properties:

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

GoodLabel and ResponseVar can only be set (enforced) when creating a creditscorecard object using creditscorecard.

References

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

[2] Refaat, M. Data Preparation for Data Mining Using SAS. Morgan Kaufmann, 2006.

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

Introduced in R2014b

Was this topic helpful?