authorID_to_titles_stem = utils.load_pickle("../pmi_data/authorID_to_titles_stem.p")                     

score_by_author = utils.load_pickle("../pmi_data/score_by_author_by_document.p")

"""
Explanation: Recommender System
The Netflix Challenge
The principle of this recommander system is the same as the Netflix Challenge:
In the nexflix challenge we start with one matrix NxM with the user in the row and the movies in the column. The matrix is not full
The goal is to factorize the matrix in 2 others matrix V=NxK and Z=KxM where K is a variable. It represents also the number of features
There is an explanation to this factorization. Indeed the matrix V represent the user and the différent features that caracterize a movie (love, horror, action, period of time,...) and the user give a score to each of those features.
In the mean time we have the matrix Z where each line is a features and each column is a movie. The goal is to describe each movie according to the features
The last step is to do a matrix multiplication among V and Z and we obtain the score a user would give to the movie
Mentor-Mentee recommender system
Is it possible to map that prblem to the Netflix Challenge. Indeed every mentor and every mentee will have their own favorite field. And we can imagine other features as well. But let's keep it simple. So if we can find a list of features to describe the mentors and to reprente what the mentee are looking for, we end up with the same representation as in the Netflix challenge:
    -user == mentee
    -movie == mentor
To fill the matrix V (the one representing the mentee) we can imagine asking question to the mentee that will help giving a score to each feautres (topics) or directly ask to give a grade to each topics. 
To fill the Z matrix (mentor) we will use the dblp file and infer k topics from the titles and give a grade to each mentor in each detected topics
The last step will be to do the matrix multiplication among 1 or many mentee and the mentor. Then assign one mentee to a mentor based one the rulse we want to apply (1-1 mapping, 1-N mapping,...)
End of explanation
"""


def scale_list(list_):
    min_ = min(list_)
    max_ = max(list_)
    diff = max_ - min_
    finale_scale = 10
    return [(i-min_)/diff * finale_scale for i in list_]

score_by_author = np.apply_along_axis(scale_list, axis=1, arr=score_by_author)

score_by_author[0]

def get_mentor(mentee):
    return np.argmax(np.dot(mentee, score_by_author.T), axis=1)

"""
Explanation: Scale all the grade between 0 (with lowest value) and 10 (the one with highest value)
End of explanation
"""


mentee1 = np.zeros(20)
mentee1[1] = 10
author_id = get_mentor([mentee1])

author_id

list(authorID_to_titles_stem.values())[author_id[0]]

"""
Explanation: Mentee should fill the array by giving a for each topic according to his preferences
End of explanation
"""


