<jupyter_start><jupyter_text>Load test set tags<jupyter_code>tag = pd.read_csv('../data-processed/full-data/pid-track-ratings-train-test-tags.csv')
tag.head()
tag =  tag[tag.train_test=='test']
tag = tag[['pid','test_first_random']].drop_duplicates()
tag = tag.rename(columns = {'test_first_random':'seed_track_order'})
tag['seed_track_order'] = tag['seed_track_order'].map({1:'first n', 0:'random n'})
tag.head()<jupyter_output><empty_output><jupyter_text>Load evaluation results<jupyter_code>evaluation_res = pd.DataFrame()
path_to_jsonfiles = '../evaluation/'
for file in os.listdir(path_to_jsonfiles):
    df0=pd.read_csv(f'{path_to_jsonfiles}{file}')
    evaluation_res = evaluation_res.append(df0)
evaluation_res.head()
evaluation_res.shape<jupyter_output><empty_output><jupyter_text>Group<jupyter_code>evaluation_res.model.unique()
evaluation_res['parent_model'] = evaluation_res['model'].map({
    'ALS':'ALS', 
    'CB_audio_features':'CB', 
    'SVD_100':'SVD', 
    'SVD_50':'SVD'})
evaluation_res.head()
evaluation_res = evaluation_res.merge(tag, how = 'left', left_on = 'pid', right_on = 'pid')
evaluation_res.head()
summary = evaluation_res.groupby(['parent_model','rating','seed_track_order'])[['R-Precision','nDCG']].mean().reset_index()
summary
summary.to_csv('../evaluation/summary.csv', index = None)<jupyter_output><empty_output><jupyter_text>Visualise<jupyter_code>summary = pd.read_csv('../evaluation/summary.csv')
fig, ax = plt.subplots(ncols=2, figsize=(12,5))
data = summary
sns.barplot(data=data, x ='parent_model', y = 'R-Precision', order = ['ALS','SVD','CB'], ax = ax[0]).set_title('R-Precision by model')
sns.barplot(data=data, x ='parent_model', y = 'nDCG',  order = ['ALS','SVD','CB'], ax = ax[1]).set_title('nDCG by model')
ax[0].set(xlabel='', ylabel='model')
ax[1].set(xlabel='', ylabel='model')
fig, ax = plt.subplots(ncols=2, figsize=(10,4))

data = summary[summary['parent_model']!='CB']
hue = 'parent_model'

sns.barplot(data=data, x ='seed_track_order', y = 'R-Precision', hue = hue, ax = ax[0]).set_title('R-Precision by model and order of seed tracks')
sns.barplot(data=data, x ='seed_track_order', y = 'nDCG', hue = hue, ax = ax[1]).set_title('nDCG by model and order of seed tracks')
ax[0].set(xlabel='', ylabel='model')
ax[0].set(xlabel='', ylabel='model')
ax[1].set(xlabel='', ylabel='model')
ax[0].get_legend().remove()
ax[1].legend(loc= 'upper left', title = 'seed tracks order', bbox_to_anchor=(1,0.5))
fig, ax = plt.subplots(ncols=2, figsize=(10,4))
data = summary[summary['parent_model']!='CB']
hue = 'parent_model'

sns.barplot(data=data, x ='rating', y = 'R-Precision', hue = hue, ax = ax[0]).set_title('R-Precision by model and rating type')
sns.barplot(data=data, x ='rating', y = 'nDCG', hue = hue, ax = ax[1]).set_title('nDCG by model and rating type')
ax[0].set(xlabel='', ylabel='model')
ax[0].set(xlabel='', ylabel='model')
ax[1].set(xlabel='', ylabel='model')
ax[0].get_legend().remove()
ax[1].legend(loc= 'upper left', title = 'rating type', bbox_to_anchor=(1,0.5))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20804710500490678, 'fraction_numerical': 0.014720314033366046, 'mean_word_length': 7.518105849582173, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '35684', 'license': 'MIT', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1189, 'n_words': 193, 'path': 'modeling-notebooks/.ipynb_checkpoints/evaluation-summary-checkpoint.ipynb', 'repo_name': 'IrynaHorova/APC-Spotify-Million-Playlists-Ironhack-Project', 'size': '3057'}