secure_learning.models.grid_cv

Module for Cross Valdation (CV) following the GridSearchCV paradigm of sklearn.

Attributes

ModelTypeTV

Classes

ParameterCollection

A collection of parameters, serves as a helper class for generation of a parameter grid.

Parameters

Helper class, used internally, to provide a set a parameters.

GridCV

Exhaustive search over specified parameter values for a model.

Module Contents

secure_learning.models.grid_cv.ModelTypeTV[source]
class secure_learning.models.grid_cv.ParameterCollection[source]

A collection of parameters, serves as a helper class for generation of a parameter grid.

solver_type: List[tno.mpc.mpyc.secure_learning.models.SolverTypes][source]
penalty: List[tno.mpc.mpyc.secure_learning.models.PenaltyTypes][source]
alpha: List[float][source]
tolerance: List[float][source]
minibatch_size: List[int | None][source]
weights_init: List[tno.mpc.mpyc.secure_learning.utils.Vector[mpyc.sectypes.SecureFixedPoint] | None][source]
nr_maxiters: List[int][source]
print_progress: List[bool] = [False][source]
secure_permutations: List[bool] = [False][source]
exponentiation: List[tno.mpc.mpyc.secure_learning.models.ExponentiationTypes][source]
class secure_learning.models.grid_cv.Parameters[source]

Helper class, used internally, to provide a set a parameters.

solver_type: tno.mpc.mpyc.secure_learning.models.SolverTypes[source]
penalty: tno.mpc.mpyc.secure_learning.models.PenaltyTypes[source]
alpha: float[source]
tolerance: float[source]
minibatch_size: int | None[source]
weights_init: tno.mpc.mpyc.secure_learning.utils.Vector[mpyc.sectypes.SecureFixedPoint] | None[source]
nr_maxiters: int[source]
print_progress: bool[source]
secure_permutations: bool[source]
exponentiation: tno.mpc.mpyc.secure_learning.models.ExponentiationTypes[source]
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.

model_type[source]
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