secure_learning.models.grid_cv¶
Module for Cross Valdation (CV) following the GridSearchCV paradigm of sklearn.
Attributes¶
Classes¶
A collection of parameters, serves as a helper class for generation of a parameter grid. | |
Helper class, used internally, to provide a set a parameters. | |
Exhaustive search over specified parameter values for a model. |
Module Contents¶
- class secure_learning.models.grid_cv.ParameterCollection[source]¶
A collection of parameters, serves as a helper class for generation of a parameter grid.
- class secure_learning.models.grid_cv.Parameters[source]¶
Helper class, used internally, to provide a set a parameters.
- class secure_learning.models.grid_cv.GridCV(model_type: ModelTypeTV, parameter_collection: ParameterCollection, X: tno.mpc.mpyc.secure_learning.utils.Matrix[mpyc.sectypes.SecureFixedPoint], y: tno.mpc.mpyc.secure_learning.utils.Vector[mpyc.sectypes.SecureFixedPoint])[source]¶
Exhaustive search over specified parameter values for a model.
- property results: List[tno.mpc.mpyc.secure_learning.utils.Vector[float]][source]¶
The results of grid cross-validation
- Returns:
Results of grid cross-validation
- Raises:
ValueError – Raised when results are not available
- async cross_validation(folds: int | List[Tuple[List[int], List[int]]]) List[tno.mpc.mpyc.secure_learning.utils.Vector[float]][source]¶
Compute cross validation over all given combinations of parameters and return the score for each set.
- Parameters:
folds – Folding sets. If set to $k$ (integer) then a KFold (from sklearn.model_selection) is used. If it is not set then KFold is called with $k=5$. It also possible to pass custom folds as a list of tuples of train and test indexes: e.g. $[([2, 3], [0, 1, 4]), ([0, 1, 3], [2, 4]), ([0, 1, 2], [3, 4])]$ is a three-fold of an array of five elements $([2, 3], [0, 1, 4])$ -> 1st fold, elements with indexes $[2, 3]$ are used in the train set, while elements with indexes $[0, 1, 4]$ are used in the test set $([0, 1, 3], [2, 4])$ -> 2nd fold, elements with indexes $[0, 1, 3]$ are used in the train set, while elements with indexes $[2, 4]$ are used in the test set $([0, 1, 2], [3, 4])$ -> 3rd fold, elements with indexes $[0, 1, 2]$ are used in the train set, while elements with indexes $[3, 4]$ are used in the test set
- Returns:
A list containing one list of score results (over different folds) for each parameters combination
- best_param_set() Tuple[float, Parameters][source]¶
Return parameter set with the best score result.
- Returns:
parameter set with the best score result
- sorted_param_set() List[Tuple[float, Parameters]][source]¶
Return a sorted list of the parameter sets with their score results
- Returns:
sorted list of the parameter sets with their score results