-
Notifications
You must be signed in to change notification settings - Fork 0
/
predict.py
29 lines (24 loc) · 840 Bytes
/
predict.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
import pickle
import os
import glob
import pandas as pd
from sklearn.metrics import mean_squared_error
list_of_files = glob.glob('embedding/*')
latest_file = max(list_of_files, key=os.path.getctime)
print ("Loading embedding:", latest_file)
embedding_file = open(latest_file,"rb")
embedding_dict = pickle.load(embedding_file)
def getMSE(a, b):
return mean_squared_error(a, b)
def getPrediction(embedding):
"""
For now return min error person as prediction.
Later on we will train the model from embedding and use that model for prediction.
"""
name = []
error = []
for key, value in embedding_dict.items():
name.append(key)
error.append(getMSE(value, embedding))
result = pd.DataFrame({'name': name, 'error': error}).sort_values('error').iloc[:5]
print (result)