forked from ZhuoSun1987/GroupLassoSVM_SAR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReportFromParaTuning.m
81 lines (72 loc) · 1.96 KB
/
ReportFromParaTuning.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
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
function [ OptimalParaArray] = ReportFromParaTuning( ReportPath,SumWeights,ReportTxtPath )
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
%
ReportStruct=importdata(ReportPath);
FolderList=ReportStruct.FolderList;
Save=0;
if nargin>2 & ~isempty(ReportTxtPath)
Save=1;
fid=fopen(ReportTxtPath,'w');
end
FieldNameList={'AccList','AUCList','SenList','SpeList','precisionList','recallList','gmeanList','fList'}
NameList={'Accuracy','AUC','Sensitivity','Specificity','percision','Recall','gmean','f_measure'}
if isempty(SumWeights)
SumWeight=zeros(1,8);
SumWeight(1)=1;
end
% for each measurements
for i=1:length(FieldNameList)
List=getfield(ReportStruct,FieldNameList{i});
Max=max(List);
Pos=find(List==Max);
disp('===================')
str=['Best ',NameList{i},' = ',num2str(Max)];
disp(str);
if Save==1
fprintf(fid,'%s','===================')
fprintf(fid,'\n');
fprintf(fid,'%s',str);
fprintf(fid,'\n');
end
for i=1:length(Pos)
str=[' ',FolderList{Pos(i)}];
disp(str);
fprintf(fid,'%s',str);
fprintf(fid,'\n');
end
disp(' ');
disp(' ');
fprintf(fid,'\n');
fprintf(fid,'\n');
fprintf(fid,'\n');
end
ExpNum=length(FolderList);
Mat=zeros(ExpNum,length(FieldNameList));
for i=1:length(FieldNameList)
List=getfield(ReportStruct,FieldNameList{i});
Mat(:,i)=List;
end
NewMeasure=Mat*reshape(SumWeights,length(SumWeights),1);
MaxNewMeasure=max(NewMeasure);
Pos=find(NewMeasure==MaxNewMeasure);
OptimalParaArray=cell(length(Pos),1);
str=['The optimal new measurement result is ',num2str(MaxNewMeasure)]
disp(str)
if Save==1
fprintf(fid,'%s',str);
fprintf(fid,'\n');
end
for i=1:length(Pos)
OptimalParaArray{i}=ReportStruct.LambdaArray{Pos(i)};
str=[' ',FolderList{Pos(i)}];
disp(str);
if Save==1
fprintf(fid,'%s',str);
fprintf(fid,'\n');
end
end
if Save==1
fclose(fid);
end
end