Mordicus.BasicAlgorithms.ScikitLearnRegressor module
- ComputeRegressionApproximation(model, scalerX, scalery, XTest)[source]
Computes the prediction of the Regressor,taking into account prelearned scalers for input and output
- Parameters:
model (sklearn.model_selection._search.GridSearchCV) – trained and optimized scikit learn regressor
scalerX (sklearn.preprocessing._data.StandardScaler) – scaler trained on input data
scalery (sklearn.preprocessing._data.StandardScaler) – scaler trained on output data
XTest (np.ndarray) – testing data
- Returns:
np.ndarray – kept eigenvalues, of size (numberOfEigenvalues)
np.ndarray – kept eigenvectors, of size (numberOfEigenvalues, numberOfSnapshots)
- GridSearchCVRegression(regressor, paramGrid, X, y)[source]
Optimizes a scikit learn regressor using gridSearchCV, using training data and target values
- Parameters:
regressor (object satisfying the scikit-learn regressors API) – input regressor to be fitted and optimized
paramGrid (dict) – of lists (of floats) containing hyperparameter values of the considered regressor
X (np.ndarray) – training data
y (np.ndarray) – target values
- Returns:
sklearn.model_selection._search.GridSearchCV – trained and optimized scikit learn regressor
sklearn.preprocessing._data.StandardScaler – scaler trained on input data
sklearn.preprocessing._data.StandardScaler – scaler trained on output data
- class MyGPR(kernel)[source]
Bases:
GaussianProcessRegressorCustomization of scikit-learn’s GaussianProcessRegressor
- set_predict_request(*, return_cov: bool | None | str = '$UNCHANGED$', return_std: bool | None | str = '$UNCHANGED$') MyGPR
Request metadata passed to the
predictmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
return_cov (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
return_covparameter inpredict.return_std (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
return_stdparameter inpredict.
- Returns:
self – The updated object.
- Return type:
object
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MyGPR
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
self – The updated object.
- Return type:
object