jrno commited on
Commit
96d268d
1 Parent(s): 8769897

Test change

Browse files
recommendation-api/server.py CHANGED
@@ -18,6 +18,7 @@ async def startup_event():
18
  global learn
19
  tasks = [asyncio.ensure_future(setup_learner(model_filename))] # assign some task
20
  learn = (await asyncio.gather(*tasks))[0]
 
21
 
22
  @app.get("/users")
23
  async def get_users(limit: int = Query(10)):
 
18
  global learn
19
  tasks = [asyncio.ensure_future(setup_learner(model_filename))] # assign some task
20
  learn = (await asyncio.gather(*tasks))[0]
21
+ print("Model initialized")
22
 
23
  @app.get("/users")
24
  async def get_users(limit: int = Query(10)):
recommendation-api/tracks.py CHANGED
@@ -1,15 +1,21 @@
1
  import pandas as pd
2
 
 
 
3
  # Read track infos and build the entry representation
4
  tracks_df = pd.read_csv('data/music_info.csv')
5
  tracks_df.fillna('', inplace=True)
6
  tracks_df["entry"] = tracks_df["name"] + ", " + tracks_df["artist"] + ", " + tracks_df["year"].astype(str)
7
 
 
 
8
  # Raw dataframe from the training set
9
  model_df = pd.read_csv('data/model.csv')
10
  model_interactions_df = model_df[['user_id', 'track_id']]
11
  model_tracks_df = model_df[['entry']].drop_duplicates()
12
 
 
 
13
  # Create a dictionary where user_id is the key and full track history value
14
  user_to_track_history_df = pd.merge(tracks_df, model_interactions_df, on='track_id', how='left').astype(str)
15
  user_to_track_history_dict = {user_id: group.drop('user_id', axis=1).to_dict('records')
@@ -46,4 +52,4 @@ def predictions_to_tracks(entries_and_predictions):
46
  track_dict = track_info.to_dict('records')[0]
47
  track_dict['score'] = score.astype(str)
48
  tracks.append(track_dict)
49
- return tracks
 
1
  import pandas as pd
2
 
3
+ print("Initializing data")
4
+
5
  # Read track infos and build the entry representation
6
  tracks_df = pd.read_csv('data/music_info.csv')
7
  tracks_df.fillna('', inplace=True)
8
  tracks_df["entry"] = tracks_df["name"] + ", " + tracks_df["artist"] + ", " + tracks_df["year"].astype(str)
9
 
10
+ print("Music info parsed")
11
+
12
  # Raw dataframe from the training set
13
  model_df = pd.read_csv('data/model.csv')
14
  model_interactions_df = model_df[['user_id', 'track_id']]
15
  model_tracks_df = model_df[['entry']].drop_duplicates()
16
 
17
+ print("Model data parsed")
18
+
19
  # Create a dictionary where user_id is the key and full track history value
20
  user_to_track_history_df = pd.merge(tracks_df, model_interactions_df, on='track_id', how='left').astype(str)
21
  user_to_track_history_dict = {user_id: group.drop('user_id', axis=1).to_dict('records')
 
52
  track_dict = track_info.to_dict('records')[0]
53
  track_dict['score'] = score.astype(str)
54
  tracks.append(track_dict)
55
+ return tracks