uqmodels packageο
Subpackagesο
- uqmodels.evaluation package
- Submodules
- uqmodels.evaluation.base_metrics module
- uqmodels.evaluation.evaluation module
- uqmodels.evaluation.metrics module
- Module contents
- uqmodels.modelization package
- Subpackages
- uqmodels.modelization.DL_estimator package
- Submodules
- uqmodels.modelization.DL_estimator.Lstm_WS_ED module
- uqmodels.modelization.DL_estimator.baseline_models module
- uqmodels.modelization.DL_estimator.data_embedding module
- uqmodels.modelization.DL_estimator.loss module
- uqmodels.modelization.DL_estimator.lstm_ed module
- uqmodels.modelization.DL_estimator.metalayers module
- uqmodels.modelization.DL_estimator.neural_network_UQ module
- uqmodels.modelization.DL_estimator.transformer_ed module
- uqmodels.modelization.DL_estimator.utils module
- Module contents
- uqmodels.modelization.ML_estimator package
- uqmodels.modelization.DL_estimator package
- Submodules
- uqmodels.modelization.UQEstimator module
- Module contents
- Subpackages
- uqmodels.postprocessing package
- Submodules
- uqmodels.postprocessing.UQKPI_Processor module
- uqmodels.postprocessing.UQ_processing module
check_UQ()
check_y_vs_pred_and_UQ_shape()
compute_Epistemic_score()
compute_PI()
fit_Epistemic_score()
fit_PI()
get_extremum_var()
get_extremum_var_TOT_and_ndUQ_ratio()
get_nominal_disentangled_UQ_ratio()
norm_var()
process_UQmeasure_to_Epistemicscore()
process_UQmeasure_to_TOT_and_E_sigma()
process_UQmeasure_to_quantile()
process_UQmeasure_to_residu()
process_UQmeasure_to_sigma()
renormalise_UQ()
split_var_dUQ()
- uqmodels.postprocessing.anomaly_processing module
- uqmodels.postprocessing.custom_UQKPI_Processor module
- Module contents
- uqmodels.preprocessing package
- Submodules
- uqmodels.preprocessing.Custom_Preprocessor module
- uqmodels.preprocessing.Preprocessor module
- uqmodels.preprocessing.data_loader module
- uqmodels.preprocessing.features_processing module
automatic_periods_detection()
build_window_representation()
check_transform_input_to_panda()
compute_FE_by_estimator()
compute_MV_features()
compute_ctx_features()
compute_feature_engeenering()
compute_pca()
compute_tsfresh_feature_engeenering()
fit_FE_by_estimator()
fit_MV_features()
fit_compute_MA_derivate()
fit_compute_lag()
fit_compute_lag_values()
fit_compute_periods()
fit_ctx_features()
fit_feature_engeenering()
fit_pca()
fit_tsfresh_feature_engeenering()
get_FE_params()
mask_corr_feature_target()
normalise_panda()
select_data()
select_data_and_context()
select_features_from_FI()
select_tsfresh_params()
- uqmodels.preprocessing.preprocessing module
Past_Moving_window_mapping()
Regular_Moving_window_mapping()
add_row()
auto_corr_reduce()
check_is_pd_date()
compute_corr_and_filter()
corrcoef_reduce()
dataset_generator_from_array()
df_interpolation_and_fusion()
df_selection()
downscale_series()
entropy()
extract_sensors_errors()
fft_reduce()
get_event_into_series()
get_k_composants()
handle_nan()
identity()
identity_split()
interpolate()
kfold_random_split()
last_reduce()
locate_near_index_values()
map_reduce()
mean_reduce()
process_irregular_data()
process_label()
process_raw_source()
random_split()
raw_analysis()
remove_rows()
rolling_statistics()
select_best_representant()
select_signal()
splitter
upscale_series()
- uqmodels.preprocessing.structure module
- Module contents
- uqmodels.visualization package
Submodulesο
uqmodels.UQModel moduleο
- class uqmodels.UQModel.UQModel(UQEstimator_initializer=<class 'uqmodels.modelization.ML_estimator.random_forest_UQ.RF_UQEstimator'>, UQEstimator_params={'beta': 0.05, 'estimator': RandomForestRegressor(ccp_alpha=1e-05, max_depth=15, max_features=0.9, max_samples=0.7, min_impurity_decrease=1e-05, min_samples_leaf=5, min_samples_split=5, n_estimators=125), 'n_jobs': 4, 'pretuned': False, 'rescale': True, 'type_UQ': 'var_A&E', 'use_biais': True, 'var_min': 1e-05}, name='UQModel', predictor=None, preprocessor=None, list_predict_KPI_processors=None, list_score_KPI_processors=None, reduc_filter=None, roll=None, cache_manager=<uqmodels.processing.Cache_manager object>, save_result=False, save_models=False, random_state=None, **kwargs)[source]ο
Bases:
BaseEstimator
UQModel class : instanciate a pipeline of model estimation, model UQ estimation and post processing as a (Fit,Predict,Score) triplet of method
- fit(X, y=None, sample_weight=None, skip_UQEstimator=False, **kwargs)[source]ο
Fit method that apply fit method of (predictor), UQEstimators, predict_KPI_processors, score_KPI_processors :param X: Features :type X: np.array :param y: Targets/observations :type y: np.array :param sample_weight: sample_weight. Defaults to None. :type sample_weight: np.array or None, optional
- fit_with_generator(data_generator, shuffle=True, **kwargs)[source]ο
Specific fit method that handle data_generator
- Parameters:
data_generator (datagenerator) β Iterative object that provide : X, y, sample_weight, x_split, context, objective, source (see data_generator)
shuffle (bool, optional) β use shuffle or not. Defaults to True.
- load(path=None, name='UQModel')[source]ο
UQ model load procedure : recovers UQ model structure, then predictor (if existe), then UQestimators
- Parameters:
path (str, optional) β path of UQmodels save if none use path store in cache manager
name (str, optional) β name of UQmodels to load uf none use UQModel name
- predict(X, name_save='output.p', **kwargs)[source]ο
Predict method that apply predictor and UQestimators predict method, then compute predict_KPIs by use transform methods of predict_KPI_Processors
- Parameters:
X (np.array) β feature
name_save (str, optional) β file_name for (Predictor) and UQEstimator outputs save file. Defaults to βoutput.pβ.
- Returns:
prediction and list of KPIs or KPI if len(list==1)
- Return type:
pred, list_KPI_output
- predict_with_generator(data_generator, **kwargs)[source]ο
specific predict method that handle data_generator
- Parameters:
data_generator (datagenerator) β Iterative object that provide : X, y, sample_weight, x_split, context, objective, source (see data_generator)
- Returns:
list of (pred, UQ)
- save(path=None, name=None)[source]ο
UQ model save procedure : recovers UQ model structure, then predictor (if existe), then UQestimators
- Parameters:
path (path, optional) β path of UQmodels save
name (name, optional) β name of UQmodels to load
- score(X, y=None, name_save='output', **kwargs)[source]ο
Score method that produce score KPI that transform y observation and (pred,UQ) UQestimator outputs into a KPI according to score_KPI_processors
- Parameters:
X (np.array) β Features
y (np.array) β Targets/obserbations
- Returns:
list_KPI_output or KPI_ouput if len(list)==1
- Return type:
list_KPI_output
- score_with_generator(data_generator, **kwargs)[source]ο
specitic score method that handle data_generator
- Parameters:
data_generator (datagenerator) β Iterative object that provide : X, y, sample_weight, x_split, context, objective, source (see data_generator)
- Returns:
list of score_KPI or score_KPI if len(list)==1
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', skip_UQEstimator: bool | None | str = '$UNCHANGED$') UQModel ο
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_UQEstimator (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
skip_UQEstimator
parameter infit
.
- Returns:
self β The updated object.
- Return type:
object
- set_predict_request(*, name_save: bool | None | str = '$UNCHANGED$') UQModel ο
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:
name_save (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
name_save
parameter inpredict
.- Returns:
self β The updated object.
- Return type:
object
- set_score_request(*, name_save: bool | None | str = '$UNCHANGED$') UQModel ο
Request metadata passed to the
score
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 toscore
if 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.Pipeline
. Otherwise it has no effect.- Parameters:
name_save (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
name_save
parameter inscore
.- Returns:
self β The updated object.
- Return type:
object
uqmodels.custom_UQModel moduleο
- class uqmodels.custom_UQModel.MultiDEEPUQModel(UQEstimator_initializer, UQEstimator_params, list_sources, cut_params=(0.001, 0.999), multiscale_anomscore_params=None, name='MultiDEEPUQModel', cache_manager=<uqmodels.processing.Cache_manager object>, save_result=True, save_models=True, with_generator=True, reduc_filter=None, random_state=None)[source]ο
Bases:
UQModel
UQModel class for UQestimators that perform multisource forecast with UQ.
- fit(X, y, sample_weight=None, skip_UQEstimator=False, shuffle=True, **kwargs)[source]ο
Fit method that apply fit method of (predictor), UQEstimators, predict_KPI_processors, score_KPI_processors :param X: Features :type X: np.array :param y: Targets/observations :type y: np.array :param sample_weight: sample_weight. Defaults to None. :type sample_weight: np.array or None, optional
- multi_score_reshape(y=None, pred=None, UQ=None, mask=None)[source]ο
Reshape from (n_sample,n_sources*s_chan) to List of n_sources (n_sample,n_chan) elements
- Parameters:
y (np.array, optional) β y to reshape or None. Defaults to None.
pred (np.array, optional) β pred to reshape or None. Defaults to None.
UQ (np.array, optional) β UQ to reshape or None. Defaults to None.
return β list_y,list_pred,list_UQ
- predict(X, name_save='output.p')[source]ο
Predict method that apply predictor and UQestimators predict method, then compute predict_KPIs by use transform methods of predict_KPI_Processors
- Parameters:
X (np.array) β feature
name_save (str, optional) β file_name for (Predictor) and UQEstimator outputs save file. Defaults to βoutput.pβ.
- Returns:
prediction and UQmeasure
- Return type:
pred, UQ
- score(X, y, **kwargs)[source]ο
Score method that produce score KPI that transform y observation and (pred,UQ) UQestimator outputs into a KPI according to score_KPI_processors
- Parameters:
X (np.array) β Features
y (np.array) β Targets/obserbations
- Returns:
(List_Pred,list_UQ),KPI_anom
- Return type:
list_KPI_output
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', shuffle: bool | None | str = '$UNCHANGED$', skip_UQEstimator: bool | None | str = '$UNCHANGED$') MultiDEEPUQModel ο
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
.shuffle (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
shuffle
parameter infit
.skip_UQEstimator (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
skip_UQEstimator
parameter infit
.
- Returns:
self β The updated object.
- Return type:
object
- set_predict_request(*, name_save: bool | None | str = '$UNCHANGED$') MultiDEEPUQModel ο
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:
name_save (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
name_save
parameter inpredict
.- Returns:
self β The updated object.
- Return type:
object
- class uqmodels.custom_UQModel.MultiUQModel(UQEstimator_initializer, UQEstimator_params, tunning_params, list_sources, list_delta=None, target_delta=None, multiscale_anomscore_params=None, models_in_ram=True, cut_params=(0.001, 0.999), name='Multi_RFUQModels', cache_manager=<uqmodels.processing.Cache_manager object>, save_models=True, save_result=True, random_state=None)[source]ο
Bases:
UQModel
Instanciation of UQModels that apply an UQestimator for each sources and combine results for compute multidimensional anomaly score
No predict_KPIs_processor Multiscale_Anomscore_processor as score_predict_KPIS_processor : to product multidimensional anomaly score matrix
- fit(X, y, sample_weight=None, skip_UQEstimator=False, **kwargs)[source]ο
Fit method that apply fit method of (predictor) for eachs source_UQEstimators, then fit the Anom_KPI_processors.
- Parameters:
X (np.array) β Features
y (np.array) β Targets/observations
sample_weight (np.array or None, optional) β sample_weight. Defaults to None.
- fit_with_generator(data_generator, skip_UQEstimator=False, shuffle=True, **kwargs)[source]ο
Specific fit method that handle data_generator
- Parameters:
data_generator (datagenerator) β Iterative object that provide : X, y, sample_weight, x_split, context, objective, source (see data_generator)
shuffle (bool, optional) β use shuffle or not. Defaults to True.
- get_model(id_source)[source]ο
Get model of an id_source
- Parameters:
model (UQEstimator) β UQEstimator to set
id_source (int) β Id_source
- predict(X, recovers_at_end=False, **kwargs)[source]ο
Predict method that applies predictor and UQestimators predict method, then computes predict_KPIs by using transform methods of predict_KPI_Processors.
- Parameters:
X (np.array) β feature
name_save (str, optional) β file_name for (Predictor) and UQEstimator outputs save file. Defaults to βoutput.pβ.
- Returns:
prediction and UQmeasure
- Return type:
pred, UQ
- predict_with_generator(data_generator, recovers_at_end=True, **kwargs)[source]ο
specific predict method that handle data_generator
- Parameters:
data_generator (datagenerator) β Iterative object that provide : X, y, sample_weight, x_split, context, objective, source (see data_generator)
- Returns:
list of (pred, UQ)
- score(X, y, **kwargs)[source]ο
Score method that produces score KPI by transforming y observation and (pred,UQ) UQestimator outputs into a KPI according to score_KPI_processors.
- Parameters:
X (np.array) β Features
y (np.array) β Targets/obserbations
- Returns:
list_KPI_output or KPI_ouput if len(list)==1
- Return type:
list_KPI_output
- score_with_generator(data_generator, recovers_at_end=True, **kwargs)[source]ο
specitic score method that handle data_generator
- Parameters:
data_generator (datagenerator) β Iterative object that provide : X, y, sample_weight, x_split, context, objective, source (see data_generator)
- Returns:
list of score_KPI or score_KPI if len(list)==1
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', skip_UQEstimator: bool | None | str = '$UNCHANGED$') MultiUQModel ο
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_UQEstimator (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
skip_UQEstimator
parameter infit
.
- Returns:
self β The updated object.
- Return type:
object
- set_model(model, id_source)[source]ο
Set model of an id_source
- Parameters:
model (UQEstimator) β UQEstimator to set
id_source (int) β Id_source
- set_predict_request(*, recovers_at_end: bool | None | str = '$UNCHANGED$') MultiUQModel ο
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:
recovers_at_end (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
recovers_at_end
parameter inpredict
.- Returns:
self β The updated object.
- Return type:
object
- class uqmodels.custom_UQModel.TADKIT_UQModel(y_shape, n_window=20, model='RF_UQ', model_params=None, epochs=30, reduc_coef=True, beta=0.001, random_state=None, cache_manager=<uqmodels.processing.Cache_manager object>)[source]ο
Bases:
UQModel
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', skip_UQEstimator: bool | None | str = '$UNCHANGED$') TADKIT_UQModel ο
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_UQEstimator (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
skip_UQEstimator
parameter infit
.
- Returns:
self β The updated object.
- Return type:
object
- set_predict_request(*, name_save: bool | None | str = '$UNCHANGED$') TADKIT_UQModel ο
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:
name_save (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
name_save
parameter inpredict
.- Returns:
self β The updated object.
- Return type:
object
- set_score_request(*, name_save: bool | None | str = '$UNCHANGED$') TADKIT_UQModel ο
Request metadata passed to the
score
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 toscore
if 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.Pipeline
. Otherwise it has no effect.- Parameters:
name_save (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
name_save
parameter inscore
.- Returns:
self β The updated object.
- Return type:
object
- class uqmodels.custom_UQModel.UQModel_KPI(UQEstimator_initializer, UQEstimator_params, name='UQModel', predictor=None, preprocessor=None, list_alpha=[0.025, 0.16, 0.84, 0.975], list_percent_escore=[0.5, 0.8, 0.95, 0.98, 0.995, 1], reduc_filter_pred=None, reduc_filter_KPI=None, roll_KPI=1, anom_with_born=False, beta=0.01, var_min=0.001, cache_manager=<uqmodels.processing.Cache_manager object>, q_Eratio=3, mode_epistemic_indicator='levels', random_state=None)[source]ο
Bases:
UQModel
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', skip_UQEstimator: bool | None | str = '$UNCHANGED$') UQModel_KPI ο
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_UQEstimator (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
skip_UQEstimator
parameter infit
.
- Returns:
self β The updated object.
- Return type:
object
- set_predict_request(*, name_save: bool | None | str = '$UNCHANGED$') UQModel_KPI ο
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:
name_save (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
name_save
parameter inpredict
.- Returns:
self β The updated object.
- Return type:
object
- set_score_request(*, name_save: bool | None | str = '$UNCHANGED$') UQModel_KPI ο
Request metadata passed to the
score
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 toscore
if 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.Pipeline
. Otherwise it has no effect.- Parameters:
name_save (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
name_save
parameter inscore
.- Returns:
self β The updated object.
- Return type:
object
uqmodels.processing moduleο
- class uqmodels.processing.Cache_manager(save_API=<function write>, load_API=<function read>, storing='', default_filename='', query_to_cache_query=None)[source]ο
Bases:
object
- default_query_to_cache_query(query, filename=None, values=None)[source]ο
default_query_to_keys : function that create a Save/Load query for the cache_manager load/save api_function from query
- Parameters:
query (_type_) β query to interpret
filename (str, optional) β default_storage_filename. Defaults to βobject.pβ.
values (obj or None, optional) β obj to store by load_API/ if None then query_to_save_API
- Returns:
dict_parameters to provide to save_API or load_API
- Return type:
dict_new_q
- load(query, filename=None)[source]ο
load obj at query + filname location using save_API
- Parameters:
query (dict) β query to interpret by query_to_cache_query
filename (str, optional) β filename of object if not provided by query. Defaults to None.
- Raises:
FileNotFoundError β _description_
FileNotFoundError β _description_
- Returns:
_description_
- Return type:
_type_
- save(query, obj, filename=None, verbose=False)[source]ο
save obj at query + filename location using load_API
- Parameters:
query (dict) β query to interpret by query_to_cache_query
obj (obj) β object to store by save_API
filename (_type_, optional) β filename of object if not provided by query. Defaults to None.
- class uqmodels.processing.Data_loader(data_loader_api=<function read>)[source]ο
Bases:
ABC
- load(dict_query)[source]ο
load form a dict_query that will be provide to the data_loader_api function
- Parameters:
dict_query (dict) β query as a dict that contains argument of the self.data_loader_api
- Raises:
FileNotFoundError β error if file not found
- Returns:
selected_data loaded by the data_loader_api function from the dict_query
- Return type:
selected_data
- class uqmodels.processing.MyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]ο
Bases:
JSONEncoder
- default(obj)[source]ο
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- class uqmodels.processing.Pipeline(data_loader=None, list_processors=[], verbose=False, skip_cache=False)[source]ο
Bases:
BaseEstimator
- fit(query, save_processor=False)[source]ο
- Apply a fiting procedure to the pipeline with data_loader and a list of processor to a query/querries_list
if no data_loader provide data instead of βqueryβ
- Parameters:
query_or_list (_type_) β Query or List of query to provide to the data_loader
- fit_transform(query_or_list, save_processor=False)[source]ο
Fit tranform procedure : apply sucessively fit then transform
- Parameters:
query_or_list (_type_) β query or list of query to apply
save_processor (bool, optional) β _description_. Defaults to False.
- Returns:
_description_
- Return type:
_type_
- set_fit_request(*, query: bool | None | str = '$UNCHANGED$', save_processor: bool | None | str = '$UNCHANGED$') Pipeline ο
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:
query (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
query
parameter infit
.save_processor (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
save_processor
parameter infit
.
- Returns:
self β The updated object.
- Return type:
object
- set_transform_request(*, query_or_list: bool | None | str = '$UNCHANGED$') Pipeline ο
Request metadata passed to the
transform
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 totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.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:
query_or_list (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) β Metadata routing for
query_or_list
parameter intransform
.- Returns:
self β The updated object.
- Return type:
object
- transform(query_or_list)[source]ο
- Apply a pipeline with data_loader and a list of processor to a query o a list of query provide a generator
If query not found in cache, Load data and tranform data using fitted processor If no data_loader provide data instead of βquery_or_listβ
- Parameters:
query_or_list (query) β Query or List of query to provide to the data_loader
- Returns:
a Data gerenator that provide returned by the last Processor of the piepline
- Yields:
generator β generator that will apply pipeline to each querries provided.
- class uqmodels.processing.Processor(name='processor', cache=None, update_query=None, **kwargs)[source]ο
Bases:
object
- fit(data=None)[source]ο
Fit Processor using data
- Parameters:
data (obj, optional) β data. Defaults to None.
- fit_transform(data=None)[source]ο
Fit Processor and apply it on data
- Parameters:
data (obj, optional) β data. Defaults to None.
- load(query=None, name=None)[source]ο
Load method to load Processor at query+name location using cache_manager
- Parameters:
query (dict, optional) β query_paramaters. Defaults to None.
name (_type_, optional) β filename of obj to load. Defaults to None.
- save(query=None, object=None, name=None)[source]ο
Save method to store object at queery+name location using cache_manager
- Parameters:
query (dict, optional) β query_paramaters. Defaults to None.
object (obj, optional) β object to store. Defaults to None.
name (_type_, optional) β filename of obj to store. Defaults to None.
- transform(data=None)[source]ο
Apply Processor to data
- Parameters:
data (obj, optional) β data. Defaults to None.
- uqmodels.processing.read(storing, keys, **kwargs)[source]ο
Read API for file management
- Parameters:
storing (str) β global path of values to read
keys (list of str) β local path as list of folder + filename as last key
- uqmodels.processing.read_function(filename)[source]ο
Auxiliar read function for file manipulation that hold csv/ pickle /json
- Parameters:
filename (str) β name of file
- Raises:
FileNotFoundError β _description_
- Returns:
values loaded
- Return type:
values
- uqmodels.processing.set_query_to_cache_query(filename, with_arborescence=False, storing=None)[source]ο
- Generate function that translate query to a cache API query
Only compatible with write/read uqmodels.processing API
- Parameters:
filename (_type_) β Name of file to store data & processor
with_arborescence (bool, optional) β store in file arborescence. Defaults to False.
- Returns:
function for cache manager object
- Return type:
query_to_cache_query
- uqmodels.processing.split_path(path)[source]ο
Split path into list of folder name using path.split iterativly.
- Parameters:
path (str) β path
uqmodels.utils moduleο
- class uqmodels.utils.GenericCalibrator(type_res='res', mode='symetric', name=None, alpha=0.1)[source]ο
Bases:
object
- uqmodels.utils.add_random_state(random_state, values)[source]ο
hold addition with possible None values
- Parameters:
random_state (int or None) β Random state
values (int) β Values to add
- Returns:
int or None
- Return type:
random_state
- uqmodels.utils.apply_conv(score, filt=None, reduc_filter=None)[source]ο
Apply naivly by dimension a convolution to s using filt as filter
- Parameters:
s (np.array) β score to 1D convolute
filt (np.array) β filter to apply
- Returns:
convoluted score
- Return type:
s
- uqmodels.utils.apply_mask(list_or_array_or_none, mask, axis=0, mode='bool_array')[source]ο
- Select subpart of an array/list_of_array/tupple using a mask and np.take function.
If list_or_array_or_none is array, then direclty apply selection on it. else if it is a Tupple or list of array apply it on array in the list/tupple structure
- Parameters:
list_or_array_or_none (_type_) β ND array (list or tupple or ND.array)
mask (_type_) β Mask as boolean array or indices array.
axis (int, optional) β axis on sub array to apply. Defaults to 1.
mode (str, optional) β if βbool_arrayβ, turn bool_array_mask into an indice_array. Defaults to βbool_arrayβ.
- Returns:
Sub_selected list of array or Ndarray
- Return type:
(List or Tuple or array or Ndarray)
- uqmodels.utils.apply_middledim_reduction(ndarray, reduc_filter=None, roll=0)[source]ο
Apply middledim using ponderate mean reduc_filter weigth or do nothing
- Parameters:
ndarray (np.array) β object to reduce
reduc_filter (np.array) β ponderate weigth for reduction
- Returns:
reduced object
- Return type:
reduced_ndarray
- uqmodels.utils.aux_tuning(model, X, Y, params=None, score='neg_mean_squared_error', n_esti=100, folds=4, random_state=None)[source]ο
Random_search with sequential k-split
- Parameters:
model (scikit model) β Estimator
X ([type]) β Features
Y ([type]) β Target
params ([type], optional) β parameter_grid. Defaults to None.
score (str, optional) β score. Defaults to βneg_mean_squared_errorβ.
n_esti (int, optional) β Number of grid try . Defaults to 100.
folds (int, optional) β Number of sequential fold. Defaults to 4.
verbose (int, optional) β [description]. Defaults to 0.
random_state (bool) β handle experimental random using seeds.
- uqmodels.utils.base_cos_freq(array, freq=[2])[source]ο
Transform 1D modulo features [1, N] in cyclic (cos,sin) features for given freq
- uqmodels.utils.compute_born(y_pred, sigma, alpha, mode='sigma')[source]ο
Compute y_upper and y_lower boundary from gaussian hypothesis (sigma or 2sigma)
- Parameters:
y_pred (array) β Mean prediction
sigma (array) β Variance estimation
alpha (float) β Misscoverage ratio
mode (str) β Distribution hypothesis
(sigma β gaussian residual hypothesis, 2sigma : gaussian positive and negative residual hypothesis)
- Returns:
Lower and upper bondary of Predictive interval
- Return type:
(y_lower,y_upper)
- uqmodels.utils.convolute_1D(array, filter=None)[source]ο
Convolution by dimension for 1 od 2D array using np.convolve
- Parameters:
array (_type_) β array_to_convolve
filter (_type_, optional) β convolution fitler. Defaults to None.
- Raises:
ValueError β dimension error
- Returns:
array_convoluted
- Return type:
array
- uqmodels.utils.corr_matrix_array(m, a)[source]ο
- Parameters:
a (numpy array)
v (true val)
- Returns:
c β correlation coefficients of v against matrix m
- Return type:
numpy array
- uqmodels.utils.cum_sum_consecutive_zero(array)[source]ο
- Count consecutive 0
1 0 1 0 0 0 -> 0 1 0 1 2 3
- Parameters:
array (_type_) β array of consecutive 0
- Returns:
_description_
- Return type:
_type_
- uqmodels.utils.cut(values, cut_min, cut_max)[source]ο
Apply percentile minimal and maximal threeshold
- Parameters:
values (_type_) β values to cut
cut_min (_type_) β percentile of the minimam cut threeshold
cut_max (_type_) β percentile of the maximal cut threeshold
- Returns:
_description_
- Return type:
_type_
- uqmodels.utils.dimensional_reduction(data, mode='umap', reducer=None, fit=True, **kwargs)[source]ο
- uqmodels.utils.fit_compute_lag(Y, lag=[1, 2, 3], delay=0)[source]ο
Create lag features from a numerical array :param Y: Target to extract lag-feature :type Y: float array :param lag: Lag number. Defaults to 3. :type lag: int, optional :param delay: Delay before 1 lag feature. Defaults to 0. :type delay: int, optional
- uqmodels.utils.format_data(self, X, y, fit=False, mode=None, flag_inverse=False)[source]ο
Feature and target Formatting
- uqmodels.utils.generate_random_state(random_state=None)[source]ο
Drawn random number is random_state is None, else return random_state
- Parameters:
random_state (int or None, optional) β random_state. Defaults to None.
- Returns:
random_state int
- Return type:
random_state
- uqmodels.utils.sizeof_fmt(num, suffix='B')[source]ο
by Fred Cirera, https://stackoverflow.com/a/1094933/1870254, modified
- uqmodels.utils.stack_and_roll(array, horizon, lag=0, seq_idx=None, step=1)[source]ο
_summary_
- Parameters:
array (_type_) β array 2D to stack and roll
horizon (_type_) β depth
lag (int, optional) β _description_. Defaults to 0.
seq_idx (_type_, optional) β _description_. Defaults to None.
step (int, optional) β _description_. Defaults to 1.
- Returns:
_description_
- Return type:
_type_
- uqmodels.utils.threshold(array, min_val=None, max_val=None)[source]ο
- Threshold an array with min_val as lower bound and max_val as upper bound
Can hold mutlidimensional threshold on last dimension
- Parameters:
array (_type_) β array nd to threeshold
min_val (val, array or) β _description_
max_val (_type_) β _description_