ApplyModels

class ctapipe.tools.apply_models.ApplyModels(**kwargs: Any)[source]

Bases: ctapipe.core.tool.Tool

Apply machine learning models to data.

This tool predicts all events at once. To apply models in the regular event loop, set the appropriate options to ctapipe-process.

Models need to be trained with TrainEnergyRegressor and TrainParticleClassifier.

Attributes Summary

aliases

chunk_size

How many subarray events to load at once for making predictions.

classes

description

examples

flags

input_url

Input dl1b/dl2 file

name

output_path

Output file

progress_bar

show progress bar during processing

reconstructor_paths

Paths to trained reconstructors to be applied to the input data

Methods Summary

setup()

Initialize components from config

start()

Apply models to input tables

Attributes Documentation

aliases: Dict[Union[str, Tuple[str, ]], Union[str, Tuple[str, str]]] = {('i', 'input'): 'ApplyModels.input_url', ('r', 'reconstructor'): 'ApplyModels.reconstructor_paths', ('o', 'output'): 'ApplyModels.output_path', 'chunk-size': 'ApplyModels.chunk_size'}
chunk_size

How many subarray events to load at once for making predictions.

classes: List[Type[Any]] = [<class 'ctapipe.io.tableloader.TableLoader'>, <class 'ctapipe.reco.sklearn.DispReconstructor'>, <class 'ctapipe.reco.hillas_intersection.HillasIntersection'>, <class 'ctapipe.reco.sklearn.EnergyRegressor'>, <class 'ctapipe.reco.sklearn.ParticleClassifier'>]
description: Union[str, ctapipe.core.traits.Unicode] = 'Apply machine learning models to data.\n\n    This tool predicts all events at once. To apply models in the\n    regular event loop, set the appropriate options to ``ctapipe-process``.\n\n    Models need to be trained with\n    `~ctapipe.tools.train_energy_regressor.TrainEnergyRegressor`\n    and\n    `~ctapipe.tools.train_particle_classifier.TrainParticleClassifier`.\n    '
examples: Union[str, ctapipe.core.traits.Unicode] = '\n    ctapipe-apply-models \\\n        --input gamma.dl2.h5 \\\n        --reconstructor energy_regressor.pkl \\\n        --reconstructor particle-classifier.pkl \\\n        --output gamma_applied.dl2.h5\n    '
flags: Dict[Union[str, Tuple[str, ]], Tuple[Union[Dict[str, Any], traitlets.config.loader.Config], str]] = {'dl1-images': ({'HDF5Merger': {'dl1_images': True}}, 'Include dl1 images'), 'dl1-parameters': ({'HDF5Merger': {'dl1_parameters': True}}, 'Include dl1 parameters'), 'no-dl1-images': ({'HDF5Merger': {'dl1_images': False}}, 'Exclude dl1 images'), 'no-dl1-parameters': ({'HDF5Merger': {'dl1_parameters': False}}, 'Exclude dl1 parameters'), 'no-progress': ({'ProcessorTool': {'progress_bar': False}}, "don't show a progress bar during event processing"), 'no-true-images': ({'HDF5Merger': {'true_images': False}}, 'Exclude true images'), 'no-true-parameters': ({'HDF5Merger': {'true_parameters': False}}, 'Exclude true parameters'), 'overwrite': ({'HDF5Merger': {'overwrite': True}, 'ApplyModels': {'overwrite': True}}, 'Overwrite output file if it exists'), 'progress': ({'ProcessorTool': {'progress_bar': True}}, 'show a progress bar during event processing'), 'true-images': ({'HDF5Merger': {'true_images': True}}, 'Include true images'), 'true-parameters': ({'HDF5Merger': {'true_parameters': True}}, 'Include true parameters')}
input_url

Input dl1b/dl2 file

name: Union[str, ctapipe.core.traits.Unicode] = 'ctapipe-apply-models'
output_path

Output file

progress_bar

show progress bar during processing

reconstructor_paths

Paths to trained reconstructors to be applied to the input data

Methods Documentation

setup()[source]

Initialize components from config

start()[source]

Apply models to input tables