-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainSI.m
145 lines (122 loc) · 4.49 KB
/
mainSI.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
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
142
143
144
145
clc
close all
clear all
folder=strcat(pwd,'\FMID5\');
addpath(folder)
fprintf('\nIntelligent Systems 2019/20\n');
fprintf('This program detects fake news automatic using metadata\n');
%% Data Processing
warning off
filenames = {'metaInputs.mat','metaTargets.mat','newsData.mat','newsDataLing2','newsDataLing'};
for kk = 1:numel(filenames)
load(filenames{kk})
end
selec = 0;
while(selec==0)
fprintf('\nPick an option for the features:\n');
fprintf('1: All Features 2: Linguistic Features Only\n');
fprintf('0: Exit program\n');
fprintf('\n');
option = input('');
valid=0;
warning on
switch(option)
case 0
valid=1;
case 1
valid=1;
features=1; %all features
testingClass1 = testingClass;
testingData1 = testingData;
trainingClass1 = trainingClass;
trainingData1 = trainingData;
case 2
valid=1;
testingClass1 = testingClassLing;
testingData1 = testingDataLing;
trainingClass1 = trainingClassLing;
trainingData1 = trainingDataLing;
features=0; %linguistic features only
end
if(valid==0)
fprintf('\nError! Invalid choice!\n');
end
if valid == 1 && option ~= 0
warning off
fprintf('Program loading...\n')
%% Results
selec2=0;
while(selec2==0)
fprintf('\nPick an option for the methods:\n');
fprintf('1: C-Means Clustering 2: K-Means Clustering\n');
fprintf('3: T-S Fuzzy Model 4: ANN\n');
fprintf('0: Press 0 if you want to go back\n');
fprintf('\n');
option2 = input('');
valid2=0;
close all
switch(option2)
case 0
valid2=1;
selec2=1;
case 1
valid2=1;
[cmeansTest,cmeansCluster,cmeansAcc,exponentValue] = cmeansClustering(trainingData1,testingData1,testingClass1);
figure (1), hold on;
plotconfusion(cmeansTest,cmeansCluster);
title('Confusion Matrix of C-Means Clustering');
figure (2), hold on;
plot(exponentValue,cmeansAcc)
title('Max Accuracy vs Exponent (m) value');
ylabel('Max Accuracy');
xlabel('Exponent (m) value');
case 2
valid2=1;
[kmeansTest,kmeansCluster] = kmeansClustering(trainingData1,testingData1,testingClass1);
plotconfusion(kmeansTest,kmeansCluster);
title('Confusion Matrix of K-Means Clustering');
case 3
valid2=1;
[MaxAccuracy,Ym,YClassOptimal,YClass,FM,clusterNumber] = fuzzyModel(trainingData1,trainingClass1,testingData1,testingClass1);
figure (1), hold on;
plotmfs(FM)
fm2tex(FM,'membershipEquations.tex');
figure (2), hold on;
plot(clusterNumber,MaxAccuracy);
title('Max Accuracy vs Number of Clusters');
ylabel('Max Accuracy');
xlabel('Number of Clusters');
figure (3), hold on;
plotconfusion(testingClass1(1,:),YClassOptimal);
title('Confusion Matrix of T-S FM Model with Optimal Threshold');
case 4
close all
valid2=1;
if features == 1
trainingData1 = metaInputs;
trainingClass1 = metaTargets;
else
trainingData1 = trainingDataLing2;
trainingClass1 = trainingClassLing2;
end
[trNN,targetsNN,outputsNN,performanceNN,errorsNN,netNN,yTst,tTst] = neuralNetwork(trainingData1,trainingClass1);
% view neural network
% view(netNN)
figure (1), plotperform(trNN)
figure (2), plottrainstate(trNN)
figure (3), plotconfusion(tTst,yTst)
title('Confusion Matrix of ANN');
figure (4), ploterrhist(errorsNN)
end
if(valid2==0)
fprintf('\nError! Invalid choice!\n');
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%First Option
elseif valid == 1 && option == 0
selec=1; %Closes the loop
fprintf('\nProgram ended.\n\n');
end
end
clear features option option2 selec selec2 valid valid2 testingClassLing...
testingDataLing trainingClassLing trainingDataLing kk folder filenames