TrainModel¶
-
class
protopipe.mva.
TrainModel
(case, feature_name_list, target_name=None)[source]¶ Bases:
object
Train classification or regressor model.
- Parameters
- case: str
Possibilities are regressor or classifier
- feature_name_list: list
List of features
- target_name: str, optional
Regression target
Methods Summary
get_optimal_model
(init_model, …)Get optimal hyperparameters and returns best model.
split_data
(data_sig, train_fraction[, …])Load and split data to build train/test samples.
Methods Documentation
-
get_optimal_model
(init_model, tuned_parameters, scoring, cv)[source]¶ Get optimal hyperparameters and returns best model.
- Parameters
- init_model: `~sklearn.base.BaseEstimator`
Model to optimise
- tuned_parameters: dict
Contains parameter names and ranges to optimise on
- scoring: str
Estimator
- cv: int
number of split for x-validation
- Returns
- ——-
- best_estimator: `~sklearn.base.BaseEstimator`
Best model
-
split_data
(data_sig, train_fraction, data_bkg=None, force_same_nsig_nbkg=False)[source]¶ Load and split data to build train/test samples.
- Parameters
- data_sig: `~pandas.DataFrame`
Data frame
- train_fraction: float
Fraction of events to build the training sample
- data_bkg: `~pandas.DataFrame`
Data frame
- force_same_nsig_nbkg: bool
If true, the same number of signal and bkg events will be used to build a classifier