-
Notifications
You must be signed in to change notification settings - Fork 1
/
Classification_LR.m
34 lines (22 loc) · 1.13 KB
/
Classification_LR.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
% Function to Cclassify data points using Logistic Regression classifier
function [Error,Predicted_Labels]=Classification_LR(Projected_Images_Training,Train_Labels,Projected_Images_Testing,Ground_Labels)
%Input
%
% Projected_Images_Training : Matrix containing projected training Images
% Projected_Images_Testing : Matrix containing projected testing Images
% Train_Labels : Training Labesl of Images
% Ground_Labels : Ground Truth for each testing Image
%
% Output
% Error : Error of classification using Logistic Regression
%
%
% Author : Sunny Verma ([email protected])
% Last_Update : 28/08/2016
%
Testing_Images=size(Projected_Images_Testing,1);
t=templateLinear('Learner','logistic','Lambda','auto','Regularization','ridge','Solver','asgd');
LR_mdl=fitcecoc(Projected_Images_Training',Train_Labels,'Coding','onevsall','Learners',t,'ObservationsIn','columns');
Predicted_Labels=predict(LR_mdl,Projected_Images_Testing);
Error=nnz(Predicted_Labels-Ground_Labels)/Testing_Images;
end