-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMEDClassifier.m
More file actions
41 lines (35 loc) · 1011 Bytes
/
MEDClassifier.m
File metadata and controls
41 lines (35 loc) · 1011 Bytes
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
35
36
37
38
39
40
41
classdef MEDClassifier
properties
aMu
bMu
end
methods
function obj = MEDClassifier(AMu, BMu)
if(nargin ~= 0)
obj.aMu = AMu;
obj.bMu = BMu;
end
end
function setMeans(obj, AMu, BMu)
obj.aMu = AMu;
obj.bMu = BMu;
end
function Y = MED_Classify(obj, Point)
distanceA = (Point - obj.aMu)' * (Point - obj.aMu);
distanceB = (Point - obj.bMu)' * (Point - obj.bMu);
[~, Y] = min([distanceA distanceB]);
end
function Y = DataClassification(obj, dataPoints)
nA = 0;
nB = 0;
for i = 1:size(dataPoints,2)
if(obj.MED_Classify(dataPoints(:,i)) == 1)
nA = nA +1;
else
nB = nB +1;
end
end
Y = [nA, nB];
end
end
end