def plot_corrected_depths_train_all(trained_models, chromosome_number=1, max_y=2): for trained_model in trained_models: train_sampled_data, _, _ = utility_train.unpickle(trained_model['path']) observed_depth_mean = _compute_observed_depth_mean(train_sampled_data) _plot_corrected_depths(train_sampled_data, observed_depth_mean, chromosome_number, title='sample of training data: ' + trained_model['annotation'], min_y=0, max_y=max_y)
def plot_costs_versus_training_size(trained_models, semilogx=True, title=None): training_set_sizes = [] costs_train = [] costs_dev = [] for trained_model in trained_models: training_set_sizes.append(get_train_args(trained_model['path'])['total number of train examples']) _, _, cost_versus_epoch = utility_train.unpickle(trained_model['path']) last_record = cost_versus_epoch.to_dict('records')[-1] costs_train.append(last_record['cost_train']) costs_dev.append(last_record['cost_dev']) fig = plt.figure() format_fig(fig) axis = fig.add_subplot(111) plot = axis.semilogx if semilogx else axis.plot plot(training_set_sizes, costs_train, 'o', label='train cost') plot(training_set_sizes, costs_dev, 'o', label='dev cost') axis.set_xlabel('training set size') if title: axis.set_title(title) format_axis(axis) plt.show()
def plot_corrected_depths_dev_all(trained_models, chromosome_number=1, show_title=True): for trained_model in trained_models: train_sampled_data, dev_data, _ = utility_train.unpickle(trained_model['path']) observed_depth_mean = _compute_observed_depth_mean(train_sampled_data) title = 'dev data: ' + trained_model['annotation'] if show_title else '' figure_file_name = trained_model['figure_file_name'] if 'figure_file_name' in trained_model else None _plot_corrected_depths(dev_data, observed_depth_mean, chromosome_number, title=title, min_y=0, max_y=3, figure_file_name=figure_file_name)
def plot_costs_all(trained_models, marker='-', start_epoch=0.01, end_epoch=1000, min_cost=2, max_cost=200, loglog=False, logx=False, logy=False): for trained_model in trained_models: train_sampled_data, _, cost_versus_epoch = utility_train.unpickle(trained_model['path']) observed_depth_mean = _compute_observed_depth_mean(train_sampled_data) print('observed_depth_mean', observed_depth_mean) _plot_costs(cost_versus_epoch, marker, _minimum_achievable_cost(train_sampled_data), _feature_independent_cost(train_sampled_data, observed_depth_mean), start_epoch, end_epoch, min_cost, max_cost, title=trained_model['annotation'], loglog=loglog, logx=logx, logy=logy)
def plot_depths_dev_all(trained_models, chromosome_number=1, min_depth=0, max_depth=None, logy_scale=False): for trained_model in trained_models: _, dev_sampled_data, _ = utility_train.unpickle(trained_model['path']) if max_depth: _plot_depths(dev_sampled_data, chromosome_number, title=trained_model['annotation'], min_depth=min_depth, max_depth=max_depth, logy_scale=logy_scale) else: _plot_depths(dev_sampled_data, chromosome_number, title=trained_model['annotation'], min_depth=min_depth, max_depth=trained_model['max_depth'], logy_scale=logy_scale)
def plot_corrected_depths_test_all(trained_models, normalized_depths=True, corrected_depths=True, chromosome_number=1, min_y=0, max_y=2, show_title=True, grid=True): for trained_model in trained_models: if 'depth_file_name' in trained_model: from utility import named_tuple from load_preprocess_data import read_depths depths = read_depths(named_tuple({'chromosome_number': chromosome_number, 'depth_file_name': trained_model['depth_file_name']})) from load_preprocess_data import compute_observed_depth_mean observed_depth_mean = compute_observed_depth_mean(depths, chromosome_number) else: train_sampled_data, _, _ = utility_train.unpickle(trained_model['path']) observed_depth_mean = _compute_observed_depth_mean(train_sampled_data) test_data = pd.read_pickle(os.path.join(trained_model['path'], trained_model['test_file_name'])) title = trained_model['annotation'] if show_title else '' figure_file_name = trained_model['figure_file_name'] if 'figure_file_name' in trained_model else None _plot_corrected_depths(test_data, observed_depth_mean, chromosome_number, title=title, min_y=min_y, max_y=max_y, normalized_depths=normalized_depths, corrected_depths=corrected_depths, figure_file_name=figure_file_name, grid=grid)