TrainParticleClassifier#
- class ctapipe.tools.train_particle_classifier.TrainParticleClassifier(**kwargs: Any)[source]#
Bases:
Tool
Tool to train a
ParticleClassifier
on dl1b/dl2 data.The tool first performs a cross validation to give an initial estimate on the quality of the estimation and then finally trains one model per telescope type on the full dataset.
Attributes Summary
How many subarray events to load at once before training on n_events (or all available) events.
Input dl1b/dl2 file for the background class.
Input dl1b/dl2 file for the signal class.
Total number of events to be used for training.
Number of threads to use for the reconstruction.
Output file for the trained reconstructor.
Random seed for sampling training events.
Fraction of signal events in all events to be used for training.
Methods Summary
finish
()Write-out trained models and cross-validation results.
setup
()Initialize components from config.
start
()Train models per telescope type.
Attributes Documentation
- aliases: StrDict = {'background': 'TrainParticleClassifier.input_url_background', 'cv-output': 'CrossValidator.output_path', 'n-events': 'TrainParticleClassifier.n_events', 'n-jobs': 'ParticleClassifier.n_jobs', 'signal': 'TrainParticleClassifier.input_url_signal', 'signal-fraction': 'TrainParticleClassifier.signal_fraction', ('o', 'output'): 'TrainParticleClassifier.output_path'}#
- chunk_size#
How many subarray events to load at once before training on n_events (or all available) events.
- classes: ClassesType = [<class 'ctapipe.io.tableloader.TableLoader'>, <class 'ctapipe.reco.sklearn.ParticleClassifier'>, <class 'ctapipe.reco.sklearn.CrossValidator'>]#
- description: str | Unicode[str, str | bytes] = '\n Tool to train a `~ctapipe.reco.ParticleClassifier` on dl1b/dl2 data.\n\n The tool first performs a cross validation to give an initial estimate\n on the quality of the estimation and then finally trains one model\n per telescope type on the full dataset.\n '#
- examples: str | Unicode[str, str | bytes] = '\n ctapipe-train-particle-classifier \\\n -c train_particle_classifier.yaml \\\n --signal gamma.dl2.h5 \\\n --background proton.dl2.h5 \\\n -o particle_classifier.pkl\n '#
- input_url_background#
Input dl1b/dl2 file for the background class.
- input_url_signal#
Input dl1b/dl2 file for the signal class.
- n_events#
Total number of events to be used for training. If not given, all available events will be used (considering
signal_fraction
).
- n_jobs#
Number of threads to use for the reconstruction. This overwrites the values in the config of each reconstructor.
- output_path#
Output file for the trained reconstructor. At the moment, pickle is the only supported format.
- random_seed#
Random seed for sampling training events.
- signal_fraction#
Fraction of signal events in all events to be used for training.
signal_fraction
= n_signal / (n_signal + n_background)
Methods Documentation