-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
44 lines (37 loc) · 1.31 KB
/
Main.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
import ParsePlay
import Interpolate
import CharacterKMeans
import ScaleScores
import pprint
import SentimentAnalysis
import ScaleTime
import LowPassFilter
import matplotlib.pyplot as plt
def getTrainTestSplit(charDict, numTest=10):
items = charDict.items()
train = dict(items[10:])
test = dict(items[:10])
return train, test
def compare(l1, l2):
x = []
for i in range(len(l1)):
x.append(i)
plt.plot(x,l1)
plt.plot(x,l2,'r')
plt.show()
def main():
charDict = ParsePlay.getAllTopChars(5) # Char Dict contains a bunch of chars w/ names as keys
charDictScaled = ScaleTime.rescaleTime(charDict)
charScores = SentimentAnalysis.turn_lines_to_score(charDictScaled)
charScoresInterpolated = Interpolate.interpolate_chars_uniformly(charScores, 100)
charScoresFiltered = LowPassFilter.lowPassAllChars(charScoresInterpolated, window_ratio=.2)
charScoresScaled = ScaleScores.scale_all_scores(charScoresFiltered)
train, test = getTrainTestSplit(charScoresScaled, numTest=1)
clusters = CharacterKMeans.characterKMeans(train, 5)
pp = pprint.PrettyPrinter()
chars = zip(*clusters)[1]
pp.pprint(chars)
newWithPredicted = CharacterKMeans.predictCluster(test, zip(*clusters)[0], charScoresScaled)
pp.pprint(newWithPredicted)
if __name__ == '__main__':
main()