-
Notifications
You must be signed in to change notification settings - Fork 2
/
calculateProbabilities.m
32 lines (28 loc) · 1.17 KB
/
calculateProbabilities.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
function [ posProbMap,negProbMap ] = calculateProbabilities(IGTable, resultTermCountInPos, resultTermCountInNeg, pos_word_count, neg_word_count)
termCountInPos_map=resultTermCountInPos;
termCountInNeg_map=resultTermCountInNeg;
featuresTable=IGTable;
%featurlarýn hem pozitif file hem de negatif filedaki Probabilityleri
%hesaplanýyor
%bir feature'ýn pozitif file'daki Probabilitysi = posProbMap'te tutuluyor
posProbMap = containers.Map('KeyType','char','ValueType','double');
%bir feature'ýn negatif file'daki Probabilitysi = negProbMap'te tutuluyor
negProbMap = containers.Map('KeyType','char','ValueType','double');
for i=1:500
feature=char(featuresTable(i,1));
if ~termCountInPos_map.isKey(feature)
freqInPos = 0;
else
freqInPos = double(termCountInPos_map(feature));
end
if ~termCountInNeg_map.isKey(feature)
freqInNeg = 0;
else
freqInNeg = double(termCountInNeg_map(feature));
end
positiveProb = double(double((freqInPos+1)/(pos_word_count+500)));
negativeProb= double(double((freqInNeg+1)/(neg_word_count+500)));
posProbMap(char(feature))=positiveProb;
negProbMap(char(feature))=negativeProb;
end
end