def predict(path):
global n
global model
parentNode = os.path.split(path)[0]
j = requests.get(FIREBASE_URL + parentNode + FIREBASE_ENDING_URL).json()
sample = np.asarray([j[x] for x in j.keys() if "x_" in x]).reshape(1, -1)
if sample.shape[1] == n:
j['y_predicted'] = model.predict_proba(sample)[0][1]
j['action'] = model.predict(sample)[0]
r = requests.put(FIREBASE_URL + parentNode + FIREBASE_ENDING_URL, data = json.dumps(j))
print "Features: ", sample
print "Prediction: ", model.predict_proba(sample)
else:
print "Couldn't make prediction, wrong dimension: ", sample.shape[1], " vs ", n
# 2nd: SSEClient that prints stuff
评论列表
文章目录