Calculate the attractive score from umg
Description: Calculate the attractive score from umg
URI: /algo/score
http method: GET
@app.route('/algo/score',methods=['GET'])
def CalculateScore():
if not request.json or 'UMG' not in request.json or 'alpha' not in request.json:
return jsonify({'score':[-1]})
alpha = request.json['alpha']
if alpha >= 1 or alpha < 0:
return jsonify({'score':[-1]})
UMG = request.json['UMG']
size = len(UMG)
M = np.asarray(UMG)
M = np.transpose(M)
print M
M = M.astype(float)
M = M * alpha
M = np.insert(M,0,1-alpha, axis = 1)
print M
R = np.ones(size+1)
R_next = np.zeros(size+1)
while not np.array_equal(R_next, R):
R = R_next
R_next = np.insert(np.dot(M,R),0,1)
R = np.delete(R_next,0,0)
return jsonify({'score':R.tolist()})