This repository was archived by the owner on Oct 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprobabilityMultiply.py
78 lines (59 loc) · 1.8 KB
/
probabilityMultiply.py
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
import pandas as pd
import numpy as np
import sklearn
import os
from subprocess import call
from sklearn.mixture import GMM
from sklearn.cluster import KMeans
from sklearn import preprocessing
from sklearn.externals import joblib
from matplotlib import pyplot
def main():
# Training PDF
# Angry_1 82
# Silence_10 19
# ... ...
clusterPDF = "/Users/kirit/BtechProject/Analysis/PDF/trainingPDF.csv"
trainingProbabilities = np.array(pd.read_csv(clusterPDF, header=None, sep=' '))
# INCOMING MATRIX
# Cluster PDF
# 0 ...
# 1 ...
# ... ...
blockPDF = "/Users/kirit/BtechProject/Analysis/testPDF"
blockProbabilities = np.array(pd.read_csv(blockPDF, header=None, sep=' '))
# TRAINING MATRIX
# 0 1 2 3 ... 11
# Angry
# Neutral
# Noise
# Hybrid
# Sad
# Silence
# Number of rows corresponds to number of emotions
# number of columns corresponds to number of clusters
trainingMatrix = np.zeros(shape=(6,12))
for i in trainingProbabilities:
x = i[0].split('_')
if "Angry" in x[0]:
trainingMatrix[0][int(x[1])] = i[1]
if "Sad" in x[0]:
trainingMatrix[1][int(x[1])] = i[1]
if "Neutral" in x[0]:
trainingMatrix[2][int(x[1])] = i[1]
if "Noise" in x[0]:
trainingMatrix[3][int(x[1])] = i[1]
if "Hybrid" in x[0]:
trainingMatrix[4][int(x[1])] = i[1]
if "Silence" in x[0]:
trainingMatrix[5][int(x[1])] = i[1]
# Each row contains the probability density for that particular cluster
incomingProbabilities = np.zeros(shape=(12,1))
for i in blockProbabilities:
incomingProbabilities[i[0]] = i[1]
sentimentProbabilities = np.dot(trainingMatrix, incomingProbabilities)
sentimentProbabilities = np.divide(sentimentProbabilities, 100) #Divide by 100 to get result in terms of percentages
print(sentimentProbabilities)
return
if __name__ == '__main__':
main()