I want to use meta-learning, specifically, stacking to combine the results of two algorithms, denoted here A and B. The results of A and B correspond to the first and second columns in the dataset 'dataset.csv' in the link, which are obtained by implementing A and B on a test dataset. The third column in 'dataset.csv' corresponds to the true class label, with 1 for positive class and 0 for negative class.
I used several algorithms as meta learner in MATLAB, including decision tree, logistic regression, naive bayes. Since cross validation was used, the predicted scores on the cross-validated observations were used to plot the ROC curve. The false positive rate and true positive rate were obtained using the code 'CalROCXY.m' in the above link. The results image are following:
I want to know why the performance of stacked model is worse than both of the base learners A and B? Is there something wrong with my workflow and code? Or it is just possible situation for meta-learning which might be due to the quality of my dataset.
Following is the main body of my Matlab code:
clear;
clc;
df = readtable('C:\Users\tuna\Desktop\dataset.csv');
X = df{:, 1:2};
Y = df{:, 3};
% Stacking algorithm A and B (with cross-validation):
% Mdl_tree = fitctree(X, Y, 'MaxNumSplits', 2, 'Leaveout', 'on');
% [Label,NegLoss,PBScore,Posterior] = kfoldPredict(Mdl_tree);
% Mdl = fitclinear(X, Y, 'Learner',"logistic",'CrossVal', 'on');
Mdl = fitcnb(X, Y,"CrossVal", 'on');
[label, PBScore] = kfoldPredict(Mdl);
% Evaluate performance using ROC curve:
[fpr_AE, tpr_AE, auc_AE] = CalROCXY([X(:, 1), Y]);
[fpr_LSA, tpr_LSA, auc_LSA] = CalROCXY([X(:, 2), Y]);
[fpr_Stack, tpr_Stack, auc_Stack] = CalROCXY([PBScore(:,2), Y]);
figure('Position', [50, 50, 400, 300]);
h1 = plot(fpr_AE, tpr_AE, 'b-', 'LineWidth', 1);hold on;
h2 = plot(fpr_LSA, tpr_LSA, 'r-', 'LineWidth', 1);
h3 = plot(fpr_Stack, tpr_Stack, 'm-', 'LineWidth', 1);
axis equal;axis tight;
plot([0, 1], [0, 1], 'k--');
xlabel('FPR');
ylabel('TPR');
legend([h1, h2, h3], {['AE(auc=', num2str(roundn(auc_AE, -2)), ')'], ...
['LSA(auc=', num2str(roundn(auc_LSA, -2)), ')'], ...
['Stacking(auc=', num2str(roundn(auc_Stack, -2)), ')']}, ...
'Location', 'southeast', 'Box',"off");