%% Bin Additional "Test" Data
% This example shows how to use the bindata function's optional input for the data to bin. If not provided, bindata bins the creditscorecard training data. However, if a different dataset needs to be binned, for example, some "test" data, this can be passed into bindata as an optional input.
% Create a creditscorecard object using the CreditCardData.mat file to load the data (using a dataset from Refaat 2011). Use the 'IDVar' argument 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.

sc = autobinning(sc);

%
% Show the bin information for 'CustAge'.

bininfo(sc,'CustAge')

%
% For the purpose of illustration, take a few rows from the original data as "test" data and display the first 10 age values in the test data.

tdata = data(101:110,:);
tdata(1:10,'CustAge')

%
% Convert the test data to WOE values. To do this, set the bindata name-value pair argument for 'OutputType' to 'WOE', passing the test data (tdata) as an optional input.

bdata = bindata(sc,tdata,'OutputType','WOE')

%
% These are the first 10 binned ages, in WOE format. The ages are mapped to the WOE values displayed internally by bininfo.

bdata(1:10,'CustAge')

% Copyright 2015 The MathWorks, Inc.