I am conducting research on credit risk prediction using neural networks and K-Nearest Neighbour models (K=10) in Matlab. The dataset has 490 samples with 19 features, from which I want to predict 1 binary output variable (the credit risk of companies, Bankrupt/Non-Bankrupt). Data is split into 75% training and 30% validation and testing.
Now I want to combine both models so get one accuracy rate, as I guess it will be higher than using only one of the NN or KNN models. My question therefore is: how to combine both to give me one accuracy rate in Matlab? I know stacking and bagging techniques exist - how to use/implement them in Matlab (and test them for their real performance)?
Simple example of the neural network setup:
input layer: 19 input variables (X1---X19), accounting ratios (liquidity profitability ... ratios), for 420 sample (companies across different years).
hidden layer: 2 hidden layers with 10 neurons each, sigmoid function, training based on percentage training and validation. Backpropagation algorithm for learning and adjusting the weights.
output layer: Y (the company status: $<0.5$ indicates bankrupt, $>0.5$ indicates non bankrupt).
Simple example of the KNN setup:
I use the KNNclassify
function with K=5 and Euclidean distance. Input and output are the same as with the ANN exmaple.
I see that can use as you said Bagging or stacking, I may try do both since Matlab has already a ready-to-use function for both. My main problem is that I cannot find a guide to combine both models to give me ONE prediction and its accuracy so my ensemble model want to do in Matlab is as follows:
- NN --> output
- KNN --> output
- Stacking or bagging
- get final output
How to achieve this?