%% Create a creditscorecard Object and Set the 'BinMissingData' Property
% Create a creditscorecard object using the CreditCardData.mat file to load the dataMissing with missing values.

load CreditCardData 
head(dataMissing,5)
fprintf('Number of rows: %d\n',height(dataMissing))
fprintf('Number of missing values CustAge: %d\n',sum(ismissing(dataMissing.CustAge)))
fprintf('Number of missing values ResStatus: %d\n',sum(ismissing(dataMissing.ResStatus)))

% Use creditscorecard with the name-value argument 'BinMissingData' set to true to bin the missing data in a separate bin.

sc = creditscorecard(dataMissing,'IDVar','CustID','BinMissingData',true);
sc = autobinning(sc);
disp(sc)

% Display bin information for numeric data for 'CustAge' that includes missing data in a separate bin labelled <missing>.

bi = bininfo(sc,'CustAge');
disp(bi)
plotbins(sc,'CustAge')

% Display bin information for categorical data for 'ResStatus' that includes missing data in a separate bin labelled <missing>.

bi = bininfo(sc,'ResStatus');
disp(bi)
plotbins(sc,'ResStatus')

% Copyright 2018 The MathWorks, Inc.