%% Display Scaled Points
% This example shows how to use formatpoints after a model is fitted to format scaled points, and then use displaypoints to display the scaled points per bin, for a given predictor in the creditscorecard model.
% Points become scaled when a range is defined. Specifically, a linear transformation from the unscaled to the scaled points is necessary. This transformation is defined either by supplying a shift and slope or by specifying the worst and best scores possible. (For more information, see formatpoints.)
% Create a creditscorecard object using the CreditCardData.mat file to load the data (using a dataset from Refaat 2011). Use the 'IDVar' argument in the creditscorecard function 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);

%
% Use the formatpoints function to scale providing the 'Worst' and 'Best' score values. The range provided below is a common score range.

sc = formatpoints(sc,'WorstAndBestScores',[300 850]);

%
% Display the points information again to verify that the points are now scaled and also display the scaled minimum and maximum scores.

[PointsInfo,MinScore,MaxScore] = displaypoints(sc)

% Notice that, as expected, the values of MinScore and MaxScore correspond to the worst and best possible scores.
% Copyright 2015 The MathWorks, Inc.