-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassifyCommR.m
More file actions
141 lines (136 loc) · 6.2 KB
/
classifyCommR.m
File metadata and controls
141 lines (136 loc) · 6.2 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
%% Function classifyCommR
% Classify the best of the set of communist rulers among a given set of
% features provided each and individually erected and peer voted.
%
%% Introduction:
% Function to take from a set of data points with their features and find
% using the features to get a set of communist rulers. Each ruler is peer
% elected and the best is selected pertaining to the voting pool
%
%% Function Operation
% Function is to take input as parameters
% #1 the data set on which the classification process is to be done.
% #2 the threshold percentage; which is used to find the nearest supporters
% using the equation pertaining to a certain feature set compared with all
% datapoints support=(max of feature - min of same feature)*threshold/100
% #3 the number of best of the communist leaders; this number defines the
% number of the communist rulers/ kings with the maximum of the
% votes/supports in their favour to be recovered from the data itself.
% The return type of the function is a cell structure of the beststanding
% datapoints that can be considered as the communist rulers their
% supporters and the number of supporters that gave it the rank in order as
% described respectively.
%% Variable List
% in the order of the first declaration
% dSetK : (Data-Set Kings) the returned cell array containing the pool
% of the best rulers considering the features and the rulers and provided
% that these rulers are promoted by dedicated votes of peers in the
% community other than themselves, along with the dedicated voters and
% the number of votes that gave the ruler his position.
% dFile : (Data File)the data file taken in as matrix input.
% thr : (Threshold)the threshold limit that is used to calculate the
% maximum support length that is required for a certain data point to be
% supported by the others in the community pool of the data-points
% and features.
% related equation :
% support=(max of feature - min of same feature)*threshold/100.
% best :(Best) the number of the best rulers that is to be returned back
% to the user of the function pertaining to the datafile and the threshold.
% r,c : row and column of the input data file (dFile)
% supThr : (Support Threshold)this is to create a support threshold
% for each feature that is used to compare and find out if other
% data-points really supports a certain data-point whose credibility
% to a ruler status is under scrutiny and will get support if the
% difference in feature is less than that which is in the support
% threshold limit.
% ##related equation :
% support=(max of feature - min of same feature)*threshold/100.
% allSupp : (All Supporters) cell structure to collect all supporters
% pertaining to a certain feature of a given data-point. This stores all
% the data-points whose feature is in the support zone for the particular
% data-point in question
% deSupp : (Dedicated Supporters) those data-points which support all the
% features of the data-point in question to raise it to a leader status.
% deSupFq : (Dedicated Suppporter Frequency) used for storing the number of
% dedicated supportive data-points supporting a certain data-point.
% i,j,k,l : loop variables used in the various 'for' loops for computing
% and moving about the elements of the matrices and cell arrays
% gSuptFreq : (General Support Frequency) used as a counter variable as
% well as an updater variable to get the number of supporters at each
% feature individually for filling up the 'allSupp' cell array.
% sepFrq : (Separate Frequency) used for counting the frequency of the
% number of appearances of the data-points concerning a single data-point
% which is in question or being tested for leadership
% supC : (Support Count) shortening the count distance used as limit
% variable for finding the number of supporters in each array of the cell
% array 'allSupp'.
% desDSFq : (Descending Dedicated Support Frequency) ordered in descending
% manner, the array for dedicated supporters' frequency (deSupFq)
% indx : (Index) indexes of the array 'deSupFq' when the elements of the
% array is ordered in descending manner.
% tmpCtr : (Temporary Counter) temporary counter to count and used as a
% loop increment variable for storing up the dSetK.
% MEx : error raised when improper cell structure is created resulting
% in bad subscripts notation. Main task of this section is to discard
% improper data orientation if created in the cell structure due to
% inadecuacy in the format of the data available. *NB: EXCEPTION AS THIS IS
% THUS IGNORED FOR THE TIME BEING SINCE THE SCENARIO OF THIS CODE'S FUTURE
% USAGE IS NOT CERTAIN AT THE TIME OF CODING.* user of this code is allowed
% permission to convert or edit the Catch phrase of the code at #109 and
% tailor as per the requirement of the problem involved.
%
%% Function Code
function [dSetK,deSupp,allSupp]=classifyCommR(dFile,thr,best)
[r,c]=size(dFile);
supThr=zeros(1,c);
for i=1:c
supThr(i)=abs(max(dFile(:,i))-min(dFile(:,i)))*(thr/100);
end
dSetK=cell(best,3);
allSupp=cell(r,c);
deSupp=cell(r,1);
deSupFq=zeros(r,1);
for i=1:r
for j=1:c
gSuptFreq=0;
for k=1:r
if(abs(dFile(i,j)-dFile(k,j))<=supThr(j) && i~=k)
gSuptFreq=gSuptFreq+1;
allSupp{i,j}(gSuptFreq)=k;
end
end
sepFrq=zeros(1,r);
for k=1:c
supC=size(allSupp{i,k});
for l=0:supC(2)
try
sepFrq(allSupp{i,j}(l))=sepFrq(allSupp{i,j}(l))+1;
catch MEx
continue
end
end
end
for k=1:r
if(sepFrq(k)==c)
deSupFq(i)=deSupFq(i)+1;
deSupp{i}(deSupFq(i))=k;
end
end
end
end
[desDSFq,indx]=sort(deSupFq,'descend');
disp('Dspx01');disp(desDSFq);
disp('Dspx02');disp(indx);
disp('Dspx03');disp(deSupp);
tmpCtr=1;
while(best>0)
dSetK{tmpCtr,1}=indx(tmpCtr);
dSetK{tmpCtr,2}=deSupp{indx(tmpCtr)};
dSetK{tmpCtr,3}=desDSFq(tmpCtr);
tmpCtr=tmpCtr+1;
best=best-1;
end
end
%% Copyrights
% (c) Programmed by Bishal Biswas
% email: b.biswas_94587@ieee.org