|
a |
|
b/Semantic Features/StackEns.m |
|
|
1 |
function [ EnsemblePrediction, EnsembleError, EnsembleSuccess, beta ] = StackEns( outputs, labels, category ) |
|
|
2 |
%StackEns Take the outputs from the various L0 classifiers and merge them |
|
|
3 |
%into a single L1 output. |
|
|
4 |
% Takes numerical values, outputs numerical values. Reccomend converting |
|
|
5 |
% to classifications after this step. Uses linear regression over |
|
|
6 |
% multiple variables (>2 variable) to merge them |
|
|
7 |
|
|
|
8 |
%Add with cross validation, currently training and testing on the same set |
|
|
9 |
|
|
|
10 |
trainFunc = @mvregress; |
|
|
11 |
evalFunc = @(X, trainFunc) X * trainFunc; |
|
|
12 |
|
|
|
13 |
[ EnsemblePrediction, EnsembleError, EnsembleSuccess, trainedStruct ] = CrossValLearn(outputs(:,:,category), labels(:,category), trainFunc, evalFunc); |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
beta = reshape(cell2mat(trainedStruct), 20, []); %Convert to right format |
|
|
17 |
beta = mean(beta,2); |
|
|
18 |
|
|
|
19 |
%end |
|
|
20 |
|