This notebook examines the algorithm tuning process.
from collections import OrderedDict
import pickle
import seaborn as sns
import pandas as pd
import skopt
import matplotlib.pyplot as plt
from skopt.plots import *
def read_opt(ds, algo):
return skopt.load(f'data/{ds}/tuning/{algo}.opt')
def opt_df(opt):
ys = pd.Series(opt.func_vals)
cols = OrderedDict()
for i, dim in enumerate(opt.space):
cols[f'p{i}'] = pd.Series([x[i] for x in opt.x_iters])
cols['y'] = -ys
if hasattr(opt, 'iter_time'):
cols['time'] = pd.Series(opt.iter_time).reindex(ys.index)
return pd.DataFrame(cols)
def improvement_threshold(opt_df, col='y'):
ymax = opt_df[col].max()
return ymax - ymax * 0.01
How does the user-user CF tuning perform?
az_uu_i = read_opt('AZ', 'user-user-imp')
az_uu_e = read_opt('AZ', 'user-user')
bx_uu_i = read_opt('BX-I', 'user-user')
bx_uu_e = read_opt('BX-E', 'user-user')
BX-E UU plots:
plot_convergence(bx_uu_e)
plot_objective(bx_uu_e)
BX-I UU:
plot_convergence(bx_uu_i)
plot_objective(bx_uu_i)
bx_als_e = read_opt('BX-E', 'als')
bx_als_i = read_opt('BX-I', 'wrls')
az_als_e = read_opt('AZ', 'als')
az_als_i = read_opt('AZ', 'wrls-imp')
plot_convergence(bx_als_e)
plot_convergence(bx_als_i)
plot_objective(bx_als_i)
plot_convergence(az_als_e)
plot_objective(az_als_e)
plot_convergence(az_als_i)
plot_objective(az_als_i)
bxe_df = opt_df(bx_als_e)
bxi_df = opt_df(bx_als_i)
bxe_df.info()
sns.scatterplot(x='p0', y='time', data=bxe_df)
plt.axvline(improvement_threshold(bxe_df), 0, 1, color='grey')
sns.scatterplot(x='y', y='time', data=bxe_df)
sns.scatterplot(x='y', y='time', data=bxe_df)
plt.vlines(bxe_df.y.max() - 0.005, 0, bxe_df.time.max())
bxi_df.info()
sns.scatterplot(x='p0', y='time', data=bxi_df)
plt.axvline(improvement_threshold(bxi_df), 0, 1, color='black')
sns.scatterplot(x='y', y='time', data=bxi_df)