Skip to content

Commit

Permalink
Merge pull request #43 from fact-project/jebuss-theta-needs-to-be-cal…
Browse files Browse the repository at this point in the history
…culated

Add notice that theta needs to be calculated after disp-regression.
  • Loading branch information
jebuss authored Dec 5, 2017
2 parents 66ed96d + 36062f3 commit b27bc8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Training requires simulated diffuse gamma-ray events.

An example configuration can be found in [examples/config_disp.yaml](examples/config_disp.yaml).

**Note: By applying the disp regressor, `Theta` wil be deleted from the feature set.**
Theta has to be calculated from the source prediction e.g. by using `fact_calculate_theta` from pyfact.


# Utility scripts

Expand Down
12 changes: 10 additions & 2 deletions klaas/scripts/apply_disp_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def main(configuration_path, data_path, disp_model_path, sign_model_path, key, c
'theta_deg_off_' + str(i),
'theta_off_rec_pos_' + str(i),
])


n_del_cols = 0

with h5py.File(data_path, 'r+') as f:
for column in columns_to_delete:
if column in f[key].keys():
Expand All @@ -68,6 +70,12 @@ def main(configuration_path, data_path, disp_model_path, sign_model_path, key, c
)
yes = True
del f[key][column]
log.warn("Deleted {} from the feature set.".format(column))
n_del_cols += 1

if n_del_cols > 0:
log.warn("Source dependent features need to be calculated from the predicted source possition. "
+ "Use e.g. `fact_calculate_theta` from https://github.com/fact-project/pyfact.")

log.info('Loading model')
disp_model = joblib.load(disp_model_path)
Expand Down Expand Up @@ -122,6 +130,6 @@ def main(configuration_path, data_path, disp_model_path, sign_model_path, key, c
append_to_h5py(f, rec_pos[:, 1], key, 'source_y_prediction')
append_to_h5py(f, disp_prediction, key, 'disp_prediction')


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='klaas',
version='0.7.0',
version='0.7.1',
description='KLAssification And regression Scripts. yay',
url='https://github.com/fact-project/klaas',
author='Kai Brügge, Maximilian Nöthe, Jens Buss',
Expand Down

0 comments on commit b27bc8a

Please sign in to comment.