def model_signal_sensitivity(models, signals): factor = -1 * np.log(0.01) results = list() signal_size = [int(signal['gaussian']['height']) for signal in signals] for model in models: model['p_values'] = list() print(model['name']) print('------------------------') test_bgs = np.load(PATH_TEST_BACKGROUNDS).reshape( model['shape']) / factor predict_bgs = model['ae'].predict(test_bgs) bgs_losses = loss_distribution(test_bgs, predict_bgs) for signal in signals: test_signal = np.load(get_path_signal(signal)).reshape( model['shape']) / factor predict_signal = model['ae'].predict(test_signal) signal_losses = loss_distribution(test_signal, predict_signal) p_value = model_efficiency_p_value(bgs_losses.numpy(), signal_losses.numpy()) print(signal['id'], 'p_value: ', p_value) model['p_values'].append(p_value) results.append(model) return signal_size, results
def create_loss_distribution(self, name, signal_id=1, file_name=''): test_bgs_data, test_signal_data = self.load_test_data(signal_id=signal_id) predict_bgs_test = self.predict(test_bgs_data) predict_signal_test = self.predict(test_signal_data) test_bgs_distribution = model_utils.loss_distribution(test_bgs_data, predict_bgs_test) test_signal_distribution = model_utils.loss_distribution(test_signal_data, predict_signal_test) model_utils.plot_histogram(test_bgs_distribution.numpy(), test_signal_distribution.numpy(), name, file_name=file_name)
def create_loss_distribution(self, name, m_5=6000, k=1000, file_name=''): test_bgs_data, test_signal_data = self.load_test_data(m_5=m_5, k=k) predict_bgs_test = self.predict(test_bgs_data) predict_signal_test = self.predict(test_signal_data) test_bgs_distribution = model_utils.loss_distribution(test_bgs_data, predict_bgs_test.reshape(test_bgs_data.shape)) test_signal_distribution = model_utils.loss_distribution(test_signal_data, predict_signal_test.reshape(test_signal_data.shape)) model_utils.plot_histogram(test_bgs_distribution.numpy(), test_signal_distribution.numpy(), name, file_name=file_name)