uqmodels.modelization.ML_estimator package๏
Submodules๏
uqmodels.modelization.ML_estimator.baseline module๏
Implementation of usual prediction wrappers.
- class uqmodels.modelization.ML_estimator.baseline.GBRQ_UQEstimator(list_estimators: List_Estimators | None = None, list_alpha: list = [0.025, 0.5, 0.975], type_UQ='quantile', name: str = 'GBRQ_UQEstimator', pretuned: bool = False, random_state: int | None = None)[source]๏
Bases:
QuantileUQEstimator
Uncertainty quantification approch based on Quantile Gradient Boosting : Instatiation OF QuantileUQEstimators using GBRQ scikilearn models.
- Attributes/properties:
name (str): Name of the UQ method for future reference. type_UQ (str): Method family among the main categories of UQUQEstimators. list_estimators (Estimator): List of quantile estimator. list_alpha : list of alpha confidence level for each quantile estimators. pretuned (bool): Whether to disable parameter model tuning.
- Mean Methods:
fit: Fit the list of quantile estimators. predict:(pred,UQ) Predict for each quantile estimators
- fit(X: Array, y: Array, skip_format=False, **kwargs) None [source]๏
Fit GBRQ_UQEstimator list using QuantileUQEstimator fit methods. :param X: Features :param y: Target values
- predict(X: Array, skip_format=False, **kwargs)[source]๏
Perform the quantile estimation using QuantileUQEstimator predict methods.
- Parameters:
X โ Features
- Returns:
Median prediction or None if Median quantile estimators is not in list_estimators UQ : List of quantiles estimatiors
- Return type:
pred
- set_fit_request(*, skip_format: bool | None | str = '$UNCHANGED$') GBRQ_UQEstimator ๏
Request metadata passed to the
fit
method.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 tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.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.Pipeline
. Otherwise it has no effect.- Parameters:
skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter infit
.- Returns:
self โ The updated object.
- Return type:
object
- set_predict_request(*, skip_format: bool | None | str = '$UNCHANGED$') GBRQ_UQEstimator ๏
Request metadata passed to the
predict
method.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 topredict
if 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.Pipeline
. Otherwise it has no effect.- Parameters:
skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter inpredict
.- Returns:
self โ The updated object.
- Return type:
object
- class uqmodels.modelization.ML_estimator.baseline.GPR_UQEstimator(name: str = 'Gaussian_Process_UQ', kernel: Kernel | None = None, gp_alpha: float = 1e-06, drop_ratio: float = 0.0, rescale: bool = False, random_state: int | None = None)[source]๏
Bases:
MeanVarUQEstimator
Uncertainty quantification approch based on Gaussian Process Regressor. Instatiation OF MeanVarUQEstimator using GP scikilearn model. Warning GP has UQ limitation : see โThe pitfalls of using Gaussian Process Regression for normative modelingโ
- fit(X, y, skip_format=False, **kwargs)[source]๏
Fit procedure of Gaussian process
- Parameters:
X โ Training vectors.
y โ Target values.
- predict(X: Array, skip_format=False, **kwargs)[source]๏
Perform the prediction task of the forecasting and uncertainty models on X.
- Parameters:
X โ Samples on which to perform the prediction.
- Returns:
- A tuple containing the forecast, the predicted lower and
upper quantiles and var.
- set_fit_request(*, skip_format: bool | None | str = '$UNCHANGED$') GPR_UQEstimator ๏
Request metadata passed to the
fit
method.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 tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.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.Pipeline
. Otherwise it has no effect.- Parameters:
skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter infit
.- Returns:
self โ The updated object.
- Return type:
object
- set_predict_request(*, skip_format: bool | None | str = '$UNCHANGED$') GPR_UQEstimator ๏
Request metadata passed to the
predict
method.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 topredict
if 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.Pipeline
. Otherwise it has no effect.- Parameters:
skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter inpredict
.- Returns:
self โ The updated object.
- Return type:
object
- class uqmodels.modelization.ML_estimator.baseline.REGML_UQEstimator(estimator=None, estimator_var=None, pretuned: bool = False, type_UQ: str = 'var', use_biais: bool = True, name: str = 'REGML_UQEstimator', var_min: float = 1e-06, rescale: bool = False, random_state: int | None = None)[source]๏
Bases:
MeanVarUQEstimator
Uncertainty quantification approch based on ML regression of bias and variance Instanciation of specific Pred-Biais-Var Regression scheme for uncertainty quantification
- fit(X: Array, y: Array, skip_format=False, **kwargs) None [source]๏
Train y_lowerh forecasting and UQ models on (X,Y).
- get_params(**kwargs) Dict_params [source]๏
Get parameters for this estimator.
- Parameters:
deep (bool, default=True) โ If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
params โ Parameter names mapped to their values.
- Return type:
dict
- predict(X: Array, skip_format=False, **kwargs)[source]๏
Perform the prediction task of the forecasting and UQ models on features (X).
- Parameters:
X โ Samples on which to perform the prediction.
- Returns:
Prediction and UQmeasure
- Return type:
pred, UQ
- set_fit_request(*, skip_format: bool | None | str = '$UNCHANGED$') REGML_UQEstimator ๏
Request metadata passed to the
fit
method.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 tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.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.Pipeline
. Otherwise it has no effect.- Parameters:
skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter infit
.- Returns:
self โ The updated object.
- Return type:
object
- set_predict_request(*, skip_format: bool | None | str = '$UNCHANGED$') REGML_UQEstimator ๏
Request metadata passed to the
predict
method.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 topredict
if 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.Pipeline
. Otherwise it has no effect.- Parameters:
skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter inpredict
.- Returns:
self โ The updated object.
- Return type:
object
uqmodels.modelization.ML_estimator.random_forest_UQ module๏
- class uqmodels.modelization.ML_estimator.random_forest_UQ.RF_UQEstimator(estimator=RandomForestRegressor(), pretuned=False, type_UQ='var', use_biais=True, rescale=True, n_jobs=4, beta=0.1, var_min=1e-05, random_state=None)[source]๏
Bases:
UQEstimator
Uncertainty quantification approch based on โlocalโ sub-sampling UQ estimation from Random forest neighboorhood extraction
- RF_extraction(X)[source]๏
Random-forest subsampling statistics extraction โ
- Parameters:
X ([array]) โ Features of elements.
- Output:
Statistics array of shape (n_obs,dim): โPredโ : Random forest forecast values โBiaisโ : RF Biais computed as the sum of Oob Tree biais
- โUQโShape of UQ depends of the type_UQ !!!
- IF mode=var:
UQ = Var RF variance computed as the sum of esidualsโ variance of the leaves
- IF mode=2-var:
UQ = (Var_bot,Var_top), !!! 2-uple of 2D array !!! Var_bot : bot variance stimation (partial sum) as sum of negative residualsโ variance of the leaves Var_top : top variance stimation (partial sum) as sum of positive residualsโ variance of the leaves
- IF mode=quantile:
UQ = (Q_bot,Q_top), !!! 2-uple of 2D array !!! โQ_botโ : Bot quantile estimation (partial sum) as ponderation of leavesโ bot quantile โQ_topโ : Top quantile estimatuon (partial sum) as ponderation of leavesโ top quantile
Other advanced statistics. โBiais_oobโ : part of Biais โVar_Eโ : Part of total variance (Law of total variance) โE_Varโ : Part of total variance (Law of total variance) โVar_oobโ : Part of total variance (related to biais)
- fit(X, y, sample_weight=None, skip_format=False, **kwargs)[source]๏
Train scikit RF model and then estimate and store leafs variance to uncertainty quantification purpose :param X: Features of the training set :type X: array :param y: Targets/Observations of the training set :type y: array
- predict(X, beta=None, skip_format=False, **kwargs)[source]๏
Predict both forecast and UQ estimations values :param X: Features of the data to forecast :type X: [type] :param beta: Miss-coverage target :type beta: [type]
Returns: pred ([array]): Forecast values UQ ([type]): UQmeasure
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', skip_format: bool | None | str = '$UNCHANGED$') RF_UQEstimator ๏
Request metadata passed to the
fit
method.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 tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.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.Pipeline
. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
sample_weight
parameter infit
.skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter infit
.
- Returns:
self โ The updated object.
- Return type:
object
- set_predict_request(*, beta: bool | None | str = '$UNCHANGED$', skip_format: bool | None | str = '$UNCHANGED$') RF_UQEstimator ๏
Request metadata passed to the
predict
method.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 topredict
if 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.Pipeline
. Otherwise it has no effect.- Parameters:
beta (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
beta
parameter inpredict
.skip_format (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) โ Metadata routing for
skip_format
parameter inpredict
.
- Returns:
self โ The updated object.
- Return type:
object
- uqmodels.modelization.ML_estimator.random_forest_UQ.get_params_dict(estimator=None, pretuned=False, type_UQ='var_A&E', use_biais=True, rescale=True, n_jobs=4, beta=0.05, var_min=1e-05, n_estimators=125, max_depth=15, min_impurity_decrease=1e-05, ccp_alpha=1e-05, max_features=0.9, max_samples=0.7, random_state=None, min_samples_leaf=5, min_samples_split=5, **kwargs)[source]๏
Provide a dict of paramaters to build an RF_UQEstimator :param estimator: RandomForestRegressor with meta-parameters :type estimator: _type_, optional :param pretuned: bool flag that freeze estimator. Defaults to False. :type pretuned: bool, optional :param type_UQ: nature of UQmeasure. Defaults to โvarโ. :type type_UQ: str, optional :param use_biais: use oob biais correction. Defaults to True. :type use_biais: bool, optional :param rescale: use rescale procedure. Defaults to True. :type rescale: bool, optional :param n_jobs: number of jobs used for parallelization purpose. Defaults to 4. :type n_jobs: int, optional :param beta: miss coverage targets in case of type_UQ = quantile :type beta: float, optional :param var_min: minimal variance. Defaults to 0.00001. :type var_min: float, optional
- Returns:
dict_parameters