lale.helpers module¶
-
exception
lale.helpers.SubschemaError(sub, sup, sub_name='sub', sup_name='super')[source]¶ Bases:
Exception
-
lale.helpers.create_instance_from_hyperopt_search_space(lale_object, hyperparams)[source]¶ Hyperparams is a n-tuple of dictionaries of hyper-parameters, each dictionary corresponds to an operator in the pipeline
-
lale.helpers.cross_val_score(estimator, X, y=None, scoring=<function accuracy_score>, cv=5)[source]¶ Use the given estimator to perform fit and predict for splits defined by ‘cv’ and compute the given score on each of the splits. :param estimator: A valid sklearn_wrapper estimator :param X, y: Valid data and target values that work with the estimator :param scoring: a scorer object from sklearn.metrics (https://scikit-learn.org/stable/modules/classes.html#module-sklearn.metrics)
Default value is accuracy_score.
- Parameters
cv – an integer or an object that has a split function as a generator yielding (train, test) splits as arrays of indices. Integer value is used as number of folds in sklearn.model_selection.StratifiedKFold, default is 5. Note that any of the iterators from https://scikit-learn.org/stable/modules/cross_validation.html#cross-validation-iterators can be used here.
- Returns
cv_results: a list of scores corresponding to each cross validation fold
-
lale.helpers.cross_val_score_track_trials(estimator, X, y=None, scoring=<function accuracy_score>, cv=5)[source]¶ Use the given estimator to perform fit and predict for splits defined by ‘cv’ and compute the given score on each of the splits.
- Parameters
estimator (A valid sklearn_wrapper estimator) –
y (X,) –
scoring (string or a scorer object created using) – https://scikit-learn.org/stable/modules/generated/sklearn.metrics.make_scorer.html#sklearn.metrics.make_scorer. A string from sklearn.metrics.SCORERS.keys() can be used or a scorer created from one of sklearn.metrics (https://scikit-learn.org/stable/modules/classes.html#module-sklearn.metrics). A completely custom scorer object can be created from a python function following the example at https://scikit-learn.org/stable/modules/model_evaluation.html The metric has to return a scalar value,
cv (an integer or an object that has a split function as a generator yielding (train, test) splits as arrays of indices.) – Integer value is used as number of folds in sklearn.model_selection.StratifiedKFold, default is 5. Note that any of the iterators from https://scikit-learn.org/stable/modules/cross_validation.html#cross-validation-iterators can be used here.
:param : :type : return: cv_results: a list of scores corresponding to each cross validation fold
-
lale.helpers.print_yaml(what, doc, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶
-
lale.helpers.println_pos(message, out_file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶