# Documentation

### This is machine translation

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

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

# score

Compute credit scores for given data

## Syntax

``Scores = score(sc)``
``Scores = score(sc, data)``
``````[Scores,Points] = score(sc)``````
``````[Scores,Points] = score(sc,data)``````

## Description

example

````Scores = score(sc)` computes the credit scores for the `creditscorecard` object’s training data. This data can be a “training” or a “live” dataset. If the `data` input argument is not explicitly provided, the `score` function determines scores for the existing `creditscorecard` object’s data.`formatpoints` supports multiple alternatives to modify the scaling of the scores and can also be used to control the rounding of points and scores, and whether the base points are reported separately or spread across predictors. Missing data translates into `NaN` values for the corresponding points, and therefore for the total score. Use `formatpoints` to modify the score behavior for rows with missing data.```

example

````Scores = score(sc, data)` computes the credit scores for the given input `data`. This data can be a “training” or a “live” dataset.`formatpoints` supports multiple alternatives to modify the scaling of the scores and can also be used to control the rounding of points and scores, and whether the base points are reported separately or spread across predictors. Missing data translates into `NaN` values for the corresponding points, and therefore for the total score. Use `formatpoints` to modify the score behavior for rows with missing data.```

example

``````[Scores,Points] = score(sc)``` computes the credit scores and points for the given data. If the `data` input argument is not explicitly provided, the `score` function determines scores for the existing `creditscorecard` object’s data.`formatpoints` supports multiple alternatives to modify the scaling of the scores and can also be used to control the rounding of points and scores, and whether the base points are reported separately or spread across predictors. Missing data translates into `NaN` values for the corresponding points, and therefore for the total score. Use `formatpoints` to modify the score behavior for rows with missing data.```

example

``````[Scores,Points] = score(sc,data)``` computes the credit scores and points for the given input `data`. This data can be a “training” or a “live” dataset. `formatpoints` supports multiple alternatives to modify the scaling of the scores and can also be used to control the rounding of points and scores, and whether the base points are reported separately or spread across predictors. Missing data translates into `NaN` values for the corresponding points, and therefore for the total score. Use `formatpoints` to modify the score behavior for rows with missing data.```

## Examples

collapse all

This example shows how to use `score` to obtain scores for the training data.

Create a `creditscorecard` object using the `CreditCardData.mat` file to load the `data` (using a dataset from Refaat 2011). Use the `'IDVar'` argument in `creditscorecard `to indicate that `'CustID'` contains ID information and should not be included as a predictor variable.

```load CreditCardData sc = creditscorecard(data,'IDVar','CustID');```

Perform automatic binning to bin for all predictors.

`sc = autobinning(sc);`

Fit a linear regression model using default parameters.

`sc = fitmodel(sc);`
```1. Adding CustIncome, Deviance = 1490.8527, Chi2Stat = 32.588614, PValue = 1.1387992e-08 2. Adding TmWBank, Deviance = 1467.1415, Chi2Stat = 23.711203, PValue = 1.1192909e-06 3. Adding AMBalance, Deviance = 1455.5715, Chi2Stat = 11.569967, PValue = 0.00067025601 4. Adding EmpStatus, Deviance = 1447.3451, Chi2Stat = 8.2264038, PValue = 0.0041285257 5. Adding CustAge, Deviance = 1441.994, Chi2Stat = 5.3511754, PValue = 0.020708306 6. Adding ResStatus, Deviance = 1437.8756, Chi2Stat = 4.118404, PValue = 0.042419078 7. Adding OtherCC, Deviance = 1433.707, Chi2Stat = 4.1686018, PValue = 0.041179769 Generalized linear regression model: status ~ [Linear formula with 8 terms in 7 predictors] Distribution = Binomial Estimated Coefficients: Estimate SE tStat pValue ________ ________ ______ __________ (Intercept) 0.70239 0.064001 10.975 5.0538e-28 CustAge 0.60833 0.24932 2.44 0.014687 ResStatus 1.377 0.65272 2.1097 0.034888 EmpStatus 0.88565 0.293 3.0227 0.0025055 CustIncome 0.70164 0.21844 3.2121 0.0013179 TmWBank 1.1074 0.23271 4.7589 1.9464e-06 OtherCC 1.0883 0.52912 2.0569 0.039696 AMBalance 1.045 0.32214 3.2439 0.0011792 1200 observations, 1192 error degrees of freedom Dispersion: 1 Chi^2-statistic vs. constant model: 89.7, p-value = 1.4e-16 ```

Score training data using the `score` function without an optional input for `data`. By default, it returns unscaled scores. For brevity, only the first ten scores are displayed.

```Scores = score(sc); disp(Scores(1:10))```
``` 1.0968 1.4646 0.7662 1.5779 1.4535 1.8944 -0.0872 0.9207 1.0399 0.8252 ```

Scale scores and display both points and scores for each individual in the training data (for brevity, only the first ten rows are displayed). For other scaling methods, and other options for formatting points and scores, use the `formatpoints` function.

```sc = formatpoints(sc,'WorstAndBestScores',[300 850]); [Scores,Points] = score(sc); disp(Scores(1:10))```
``` 602.0394 648.1988 560.5569 662.4189 646.8109 702.1398 453.4572 579.9475 594.9064 567.9533 ```
`disp(Points(1:10,:))`
``` CustAge ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance _______ _________ _________ __________ _______ _______ _________ 95.256 62.421 56.765 121.18 116.05 86.224 64.15 126.46 82.276 105.81 121.18 62.107 86.224 64.15 93.256 62.421 105.81 76.585 116.05 42.287 64.15 95.256 82.276 105.81 121.18 60.719 86.224 110.96 126.46 82.276 105.81 121.18 60.719 86.224 64.15 126.46 82.276 105.81 121.18 116.05 86.224 64.15 48.727 82.276 56.765 53.208 62.107 86.224 64.15 95.256 113.58 105.81 121.18 62.107 42.287 39.729 95.256 62.421 56.765 121.18 62.107 86.224 110.96 95.256 82.276 56.765 121.18 62.107 86.224 64.15 ```

This example shows how to use `score` to obtain scores for a new dataset (for example, a validation or a test dataset) using the optional `'data'` input in the `score` function.

Create a `creditscorecard` object using the `CreditCardData.mat` file to load the `data` (using a dataset from Refaat 2011). Use the `'IDVar'` argument in `creditscorecard `to indicate that `'CustID'` contains ID information and should not be included as a predictor variable.

```load CreditCardData sc = creditscorecard(data,'IDVar','CustID');```

Perform automatic binning to bin for all predictors.

`sc = autobinning(sc);`

Fit a linear regression model using default parameters.

`sc = fitmodel(sc);`
```1. Adding CustIncome, Deviance = 1490.8527, Chi2Stat = 32.588614, PValue = 1.1387992e-08 2. Adding TmWBank, Deviance = 1467.1415, Chi2Stat = 23.711203, PValue = 1.1192909e-06 3. Adding AMBalance, Deviance = 1455.5715, Chi2Stat = 11.569967, PValue = 0.00067025601 4. Adding EmpStatus, Deviance = 1447.3451, Chi2Stat = 8.2264038, PValue = 0.0041285257 5. Adding CustAge, Deviance = 1441.994, Chi2Stat = 5.3511754, PValue = 0.020708306 6. Adding ResStatus, Deviance = 1437.8756, Chi2Stat = 4.118404, PValue = 0.042419078 7. Adding OtherCC, Deviance = 1433.707, Chi2Stat = 4.1686018, PValue = 0.041179769 Generalized linear regression model: status ~ [Linear formula with 8 terms in 7 predictors] Distribution = Binomial Estimated Coefficients: Estimate SE tStat pValue ________ ________ ______ __________ (Intercept) 0.70239 0.064001 10.975 5.0538e-28 CustAge 0.60833 0.24932 2.44 0.014687 ResStatus 1.377 0.65272 2.1097 0.034888 EmpStatus 0.88565 0.293 3.0227 0.0025055 CustIncome 0.70164 0.21844 3.2121 0.0013179 TmWBank 1.1074 0.23271 4.7589 1.9464e-06 OtherCC 1.0883 0.52912 2.0569 0.039696 AMBalance 1.045 0.32214 3.2439 0.0011792 1200 observations, 1192 error degrees of freedom Dispersion: 1 Chi^2-statistic vs. constant model: 89.7, p-value = 1.4e-16 ```

For the purpose of illustration, suppose that a few rows from the original data are our "new" data. Use the optional `data` input argument in the `score` function to obtain the scores for the `newdata`.

```newdata = data(10:20,:); Scores = score(sc,newdata)```
```Scores = 0.8252 0.6553 1.2443 0.9478 0.5690 1.6192 0.4899 0.3824 0.2945 1.4401 ```

## Input Arguments

collapse all

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

(Optional) Dataset to be scored, specified as a MATLAB® table where each row corresponds to individual observations. The `data` must contain columns for each of the predictors in the `creditscorecard` object.

## Output Arguments

collapse all

Scores for each observation, returned as a vector.

Points per predictor for each observation, returned as a table.

## Algorithms

The score of an individual i is given by the formula

`Score(i) = Shift + Slope*(b0 + b1*WOE1(i) + b2*WOE2(i)+ ... +bp*WOEp(i))`

where bj is the coefficient of the j-th variable in the model, and WOEj(i) is the Weight of Evidence (WOE) value for the i-th individual corresponding to the j-th model variable. `Shift` and `Slope` are scaling constants that can be controlled with `formatpoints`.

If the data for individual i is in the i-th row of a given dataset, to compute a score, the data(i,j) is binned using existing binning maps, and converted into a corresponding Weight of Evidence value `WOE`j(i). Using the model coefficients, the unscaled score is computed as

` s = b0 + b1*WOE1(i) + ... +bp*WOEp(i).`

For simplicity, assume in the description above that the j-th variable in the model is the j-th column in the data input, although, in general, the order of variables in a given dataset does not have to match the order of variables in the model, and the dataset could have additional variables that are not used in the model.

The formatting options can be controlled using `formatpoints`.

## 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?

Download ebook