Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dl1 to dl2 script (Less required memory and less required step) #1224

Merged
merged 5 commits into from
Feb 27, 2024

Conversation

SeiyaNozaki
Copy link
Collaborator

This PR updates the dl1 to dl2 step:

  • Load each random forest model just before using it. Now the script loads all models at the beginning of the script and it consumes much memory. Just pass the model path to apply_models. This option was already implemented in apply_models, but not used for the script before.
  • This script applies the particle classification models to the data twice for gammaness and reco_type. But reco_type can be set based on gammaness as suggested by @maxnoe here. Even, we can remove reco_type which will not be used for the analysis.
    Extra srcdep parameters and limit the offset of gamma MC for training #1077 (comment)

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 72.87%. Comparing base (1713092) to head (24ecab8).
Report is 65 commits behind head on main.

Files Patch % Lines
lstchain/scripts/lstchain_dl1_to_dl2.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1224      +/-   ##
==========================================
+ Coverage   72.67%   72.87%   +0.19%     
==========================================
  Files         132      133       +1     
  Lines       13655    13825     +170     
==========================================
+ Hits         9924    10075     +151     
- Misses       3731     3750      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -731,6 +730,9 @@ def apply_models(dl1,

# gammaness is the prediction probability for the first class (0)
dl2['gammaness'] = probs[:, 0]
col = list(classifier.classes_).index(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you get the col automtaically.. but the line above still uses the hard-coded index

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SeiyaNozaki could you move line 733 up one line and use col in 732?
After that we can merge I think

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I forgot to implement @maxnoe's comment.. now implemented!

@SeiyaNozaki
Copy link
Collaborator Author

Concerning the first point, it was on purpose for multiple input files...
#985

So I will modify codes like

  • If there is a single input file, each model will be loaded just before it is used
  • If there are multiple input files, all modes will be loaded once at the beginning and there will be no reload of models for each file

@SeiyaNozaki
Copy link
Collaborator Author

I realized I didn't read carefully comments from @gabemery during the school... sorry!

gabemery
gabemery previously approved these changes Feb 15, 2024
@@ -731,6 +730,9 @@ def apply_models(dl1,

# gammaness is the prediction probability for the first class (0)
dl2['gammaness'] = probs[:, 0]
col = list(classifier.classes_).index(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SeiyaNozaki could you move line 733 up one line and use col in 732?
After that we can merge I think

@vuillaut vuillaut merged commit fdb1a65 into main Feb 27, 2024
9 checks passed
@vuillaut vuillaut deleted the update_dl1_to_dl2_script branch February 27, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants