0001
0002
0003
0004
0005
0006
0007
0008 datasetName = 'iris';
0009
0010
0011
0012
0013
0014
0015 load(strcat(datasetName, '_dataset'));
0016 eval(sprintf('x = %sInputs;', datasetName));
0017 eval(sprintf('y = %sTargets;', datasetName));
0018 x = x';
0019 y = y';
0020 numClasses = size(y, 2);
0021 [~,y] = max(y,[],2);
0022
0023 numFeatures = size(x, 2);
0024 numInstances = size(x, 1);
0025
0026
0027 disp(['Dataset Name ' datasetName]);
0028 disp(['Number of Classes ' num2str(numClasses)]);
0029 disp(['Number of Instances ' num2str(numInstances)]);
0030 disp(['Number of Features ' num2str(numFeatures)]);
0031
0032
0033
0034
0035 fprintf('===========\n');
0036 fprintf('Basic Usage\n');
0037 fprintf('===========\n');
0038
0039
0040 lcl = LogitBooster(SVMRegressor(), numClasses);
0041
0042
0043 fprintf('\tTraining Classifier for 5 iterations');
0044 [lcl, learnErr] = learn(lcl, x, y, 5);
0045 fprintf('\tLearning Error %f\n', learnErr);
0046
0047 fprintf('\t-----\n');
0048 fprintf('\tTesting Classifier\n');
0049 outs = computeOutputs(lcl, x);
0050
0051 err = sum(outs ~= y) / numInstances;
0052 fprintf('\tLearning Error %f\n', err);
0053
0054
0055 fprintf('\t[predicted outputs : correct outputs]\n');
0056 fprintf('\t\t%d\t\t%d\t\n',outs(1:5, :), y(1:5 , :));
0057
0058
0059
0060 fprintf('==================\n');
0061 fprintf('Display Classifier\n');
0062 fprintf('==================\n');
0063
0064 fprintf('\tDisplay Classifier Before Learning\n\t===>\n');
0065 lcl = LogitBooster(SVMRegressor(), numClasses);
0066 display(lcl);
0067 fprintf('\t<===\n');
0068
0069 fprintf('\tDisplay Classifier After Learning\n===>\n');
0070 lcl = learn(lcl, x, y, 2);
0071 display(lcl);
0072 fprintf('\t<===\n');
0073
0074
0075
0076 fprintf('========================\n');
0077 fprintf('Add More Boosting Stages\n');
0078 fprintf('========================\n');
0079
0080 lcl = LogitBooster(SVMRegressor(), numClasses);
0081
0082 fprintf('\tTraining Classifier for 3 iterations\n');
0083 lcl = learn(lcl, x, y, 3);
0084 fprintf('\t------------\n');
0085 fprintf('\tTraining Classifier for 3 more iterations\n');
0086 [~, learnErr] = learn(lcl, x, y, 6);
0087 fprintf('\tLearning Error %f\n', learnErr);
0088
0089
0090
0091 fprintf('===================================================\n');
0092 fprintf('Add Boost Stages till reaching a required Err Bound\n');
0093 fprintf('===================================================\n');
0094
0095 lcl = LogitBooster(SVMRegressor(), numClasses);
0096 [lcl, learnErr] = learn(lcl, x, y, Inf, NaN, 0.02);
0097 fprintf('\tLearning Error %f\n', learnErr);