forked from moreo/QuaPy
adding broken bar plot
This commit is contained in:
parent
1ae45f8b9f
commit
027e18f1e7
|
@ -61,6 +61,8 @@ nice = {
|
||||||
'Average': 'Average',
|
'Average': 'Average',
|
||||||
'EMdiag':'EM$_{diag}$', 'EMfull':'EM$_{full}$', 'EMtied':'EM$_{tied}$', 'EMspherical':'EM$_{sph}$',
|
'EMdiag':'EM$_{diag}$', 'EMfull':'EM$_{full}$', 'EMtied':'EM$_{tied}$', 'EMspherical':'EM$_{sph}$',
|
||||||
'VEMdiag':'VEM$_{diag}$', 'VEMfull':'VEM$_{full}$', 'VEMtied':'VEM$_{tied}$', 'VEMspherical':'VEM$_{sph}$',
|
'VEMdiag':'VEM$_{diag}$', 'VEMfull':'VEM$_{full}$', 'VEMtied':'VEM$_{tied}$', 'VEMspherical':'VEM$_{sph}$',
|
||||||
|
'epaccmaemae1k': 'E(PACC)$_\mathrm{AE}$',
|
||||||
|
'quanet': 'QuaNet'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ os.makedirs(plotdir, exist_ok=True)
|
||||||
|
|
||||||
N_RUNS = N_FOLDS * N_REPEATS
|
N_RUNS = N_FOLDS * N_REPEATS
|
||||||
|
|
||||||
def gather_results(methods, error_name):
|
def gather_results(methods, error_name, resultdir):
|
||||||
method_names, true_prevs, estim_prevs, tr_prevs = [], [], [], []
|
method_names, true_prevs, estim_prevs, tr_prevs = [], [], [], []
|
||||||
for method in methods:
|
for method in methods:
|
||||||
for run in range(N_RUNS):
|
for run in range(N_RUNS):
|
||||||
|
@ -35,7 +35,7 @@ def plot_error_by_drift(methods, error_name, logscale=False, path=None):
|
||||||
print('plotting error by drift')
|
print('plotting error by drift')
|
||||||
if path is not None:
|
if path is not None:
|
||||||
path = join(path, f'error_by_drift_{error_name}.{plotext}')
|
path = join(path, f'error_by_drift_{error_name}.{plotext}')
|
||||||
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name)
|
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name, resultdir)
|
||||||
qp.plot.error_by_drift(
|
qp.plot.error_by_drift(
|
||||||
method_names,
|
method_names,
|
||||||
true_prevs,
|
true_prevs,
|
||||||
|
@ -54,7 +54,7 @@ def diagonal_plot(methods, error_name, path=None):
|
||||||
print('plotting diagonal plots')
|
print('plotting diagonal plots')
|
||||||
if path is not None:
|
if path is not None:
|
||||||
path = join(path, f'diag_{error_name}')
|
path = join(path, f'diag_{error_name}')
|
||||||
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name)
|
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name, resultdir)
|
||||||
qp.plot.binary_diagonal(method_names, true_prevs, estim_prevs, pos_class=1, title='Positive', legend=True, show_std=True, savepath=f'{path}_pos.{plotext}')
|
qp.plot.binary_diagonal(method_names, true_prevs, estim_prevs, pos_class=1, title='Positive', legend=True, show_std=True, savepath=f'{path}_pos.{plotext}')
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def binary_bias_global(methods, error_name, path=None):
|
||||||
print('plotting bias global')
|
print('plotting bias global')
|
||||||
if path is not None:
|
if path is not None:
|
||||||
path = join(path, f'globalbias_{error_name}')
|
path = join(path, f'globalbias_{error_name}')
|
||||||
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name)
|
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name, resultdir)
|
||||||
qp.plot.binary_bias_global(method_names, true_prevs, estim_prevs, pos_class=1, title='Positive', savepath=f'{path}_pos.{plotext}')
|
qp.plot.binary_bias_global(method_names, true_prevs, estim_prevs, pos_class=1, title='Positive', savepath=f'{path}_pos.{plotext}')
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,15 +70,15 @@ def binary_bias_bins(methods, error_name, path=None):
|
||||||
print('plotting bias local')
|
print('plotting bias local')
|
||||||
if path is not None:
|
if path is not None:
|
||||||
path = join(path, f'localbias_{error_name}')
|
path = join(path, f'localbias_{error_name}')
|
||||||
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name)
|
method_names, true_prevs, estim_prevs, tr_prevs = gather_results(methods, error_name, resultdir)
|
||||||
qp.plot.binary_bias_bins(method_names, true_prevs, estim_prevs, pos_class=1, title='Positive', legend=True, savepath=f'{path}_pos.{plotext}')
|
qp.plot.binary_bias_bins(method_names, true_prevs, estim_prevs, pos_class=1, title='Positive', legend=True, savepath=f'{path}_pos.{plotext}')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
plot_error_by_drift(METHODS, error_name='ae', path=plotdir)
|
||||||
|
|
||||||
plot_error_by_drift(METHODS, error_name='ae', path=plotdir)
|
diagonal_plot(METHODS, error_name='ae', path=plotdir)
|
||||||
|
|
||||||
diagonal_plot(METHODS, error_name='ae', path=plotdir)
|
binary_bias_global(METHODS, error_name='ae', path=plotdir)
|
||||||
|
|
||||||
binary_bias_global(METHODS, error_name='ae', path=plotdir)
|
binary_bias_bins(METHODS, error_name='ae', path=plotdir)
|
||||||
|
|
||||||
binary_bias_bins(METHODS, error_name='ae', path=plotdir)
|
|
||||||
|
|
|
@ -228,10 +228,10 @@ def error_by_drift(method_names, true_prevs, estim_prevs, tr_prevs, n_bins=20, e
|
||||||
if show_std:
|
if show_std:
|
||||||
ax.fill_between(xs, ys-ystds, ys+ystds, alpha=0.25)
|
ax.fill_between(xs, ys-ystds, ys+ystds, alpha=0.25)
|
||||||
|
|
||||||
# xs = bins[:-1]
|
xs = bins[:-1]
|
||||||
# ys = inds_histogram_global
|
ys = inds_histogram_global
|
||||||
# print(xs.shape, ys.shape)
|
print(xs.shape, ys.shape)
|
||||||
# ax.errorbar(xs, ys, label='density')
|
ax.errorbar(xs, ys, label='density')
|
||||||
|
|
||||||
ax.set(xlabel=f'Distribution shift between training set and test sample',
|
ax.set(xlabel=f'Distribution shift between training set and test sample',
|
||||||
ylabel=f'{error_name.upper()} (true distribution, predicted distribution)',
|
ylabel=f'{error_name.upper()} (true distribution, predicted distribution)',
|
||||||
|
|
Loading…
Reference in New Issue