%% Obtain Scores for Training Data
% 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);

%
% 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))

%
% 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))
disp(Points(1:10,:))

% Copyright 2015 The MathWorks, Inc.