import json import numpy as np def get_model(): with open('model_spec/base_dummy_playlist.json') as mm: model = json.load(mm) return model def streams(pop_5, playlists): """Apply streams model based on popularity after 5 days and playlist that the track exists on Parameters ---------- pop_5: int Popularity after 5 days playlists: set[String] Set with playlist ids Returns ------- Predicted total streams after 5 days INCLUDING the first five days """ model = get_model() play_list_contribution = sum([model[pp] for pp in playlists]) return np.exp(model['const'] + pop_5 * model['pop_5'] + play_list_contribution)