%% Display Bin Information and Binning Map for Numeric Data
% Create a creditscorecard object using the CreditCardData.mat file to load the data (using a dataset from Refaat 2011).

load CreditCardData 
sc = creditscorecard(data);

%
% The predictor CustIncome is numeric. By default, each value of the predictor is placed in a separate bin.

bi = bininfo(sc,'CustIncome')

%
% Reduce the number of bins using the autobinning function (the modifybins function can also be used).

sc = autobinning(sc,'CustIncome');

%
% Display the updated bin information. The binning map or rules for numeric data are summarized as "cut points," returned as an optional output (cp).

[bi,cp] = bininfo(sc,'CustIncome')

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

cp(2) = [];
sc = modifybins(sc,'CustIncome','CutPoints',cp,'MinValue',0);

%
% Display the updated bin information.

[bi,cp,mv] = bininfo(sc,'CustIncome')

% Note, it is recommended to avoid having bins with frequencies of zero because they lead to infinite or undefined (NaN) statistics. Use the modifybins or autobinning functions to modify bins.
% Copyright 2012 The MathWorks, Inc.