We want to study the compatibility of a user called A with another user B. I am interested in calculating similarity between 2 vectors of users traits: UserB(T1_B,T2_B) and OptUser(Rot(T1_A),-Rot(T2_A)). I used cosine_similarity as distance metric. However this similarity has to be a number between 0 and 1. Therefore cosine can't be the perfect metric (it is between -1 and 1). So, I opt to use angular distance metric. It can be used to compute a similarity function bounded between 0 and 1, inclusive.
- angular_distance = cos^-1(cosine_similarity)/Pi
- angular_similarity = 1- angular_distance
Given a POST request, with a body (JSON object) containing the traits of each user : [ {"t1":"value","t2":"value},{"t1":"value","t2":"value}} ]. We use this data to compute the angular similarity between two users as mentioned above.
pip install -r requirements.txt
Setting environment variables of flask
:
export FLASK_ENV=development
export FLASK_APP=$(pwd)/app.py
flask run
๐ค Iheb KILANI