%% Merge Bins for Numerical and Categorical Predictors
% Create a creditscorecard object (using a dataset from Refaat 2011).

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

%
% For the numerical predictor CustAge, use the modifybins function to set the following cut points:

cp = [25 37 49 65];
sc = modifybins(sc,'CustAge','CutPoints',cp,'MinValue',0,'MaxValue',75);
bininfo(sc,'CustAge')

%
% Use the modifybins function to merge the 2nd and 3rd bins.

sc = modifybins(sc,'CustAge','CutPoints',cp([1 3 4]));
bininfo(sc,'CustAge')

%
% Display bin information for the categorical predictor ResStatus.

[bi,cg] = bininfo(sc,'ResStatus');
disp(bi)

%
% Use the modifybins function to merge categories 2 and 3.

cg.BinNumber(3) = 2;
sc = modifybins(sc,'ResStatus','CatGrouping',cg);
bininfo(sc,'ResStatus')

% Copyright 2015 The MathWorks, Inc.