build_models
- lstchain.reco.dl1_to_dl2.build_models(filegammas, fileprotons, save_models=True, path_models='./', free_model_memory=True, energy_min=-inf, custom_config=None)
Uses MC data to train Random Forests for Energy and DISP reconstruction and G/H separation and returns the trained RFs. The passed config superseeds the standard configuration. Here is the complete workflow with the number of events selected from the config:
graph LR GAMMA[gammas] -->|#`gamma_regressors`| REG(regressors) --> DISK GAMMA --> S(split) S --> |#`gamma_tmp_regressors`| g_train S --> |#`gamma_classifier`| g_test g_train --> tmp_reg(tmp regressors) tmp_reg --- A[ ]:::empty g_test --- A A --> g_test_dl2 g_test_dl2 --- D[ ]:::empty protons -------- |#`proton_classifier`| D D --> cls(classifier) cls--> DISK classDef empty width:0px,height:0px;
- Parameters:
- filegammas: string
path to the file with MC gamma events
- fileprotons: string
path to the file with MC proton events
- save_models: bool
True to save the trained models on disk
- path_models: string
path of a directory where to save the models. if it does exist, the directory is created
- free_model_memory: bool
If True RF models are freed after use and not returned
- energy_min: float
Cut in intensity of the showers for training RF
- custom_config: dictionnary
Modified configuration to update the standard one
- test_size: float or int
If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the absolute number of test samples. If None, it will be set to 0.25.
- Returns:
- if config[‘disp_method’] == ‘disp_vector’:
return reg_energy, reg_disp_vector, cls_gh
- elif config[‘disp_method’] == ‘disp_norm_sign’:
return reg_energy, reg_disp_norm, cls_disp_sign, cls_gh
- Raises:
- ValueError
If the requested number of gamma events in the config for the training of the classifier is not valid. See config[“n_training_events”]