Custom extensions of sklearn functionalities¶
Custom expansions of sklearn
functionalities.
Note
This module provides custom expansions of some sklearn
classes and
functions which are necessary to fit the purposes for the desired
functionalities of the MLR module. As
long-term goal we would like to include these functionalities to the
sklearn
package since we believe these additions might be helpful for
everyone. This module serves as interim solution. To ensure that all features
are properly working this module is also covered by extensive tests.
Parts of this code have been copied from sklearn
.
License: BSD 3-Clause License
Copyright (c) 2007-2020 The scikit-learn developers. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Classes:
|
Expand |
|
Expand |
|
Expand |
|
|
|
Transformer step of a feature selection estimator. |
Functions:
|
|
|
Get transformer step of RFECV estimator. |
|
Perform exhaustive feature selection. |
- class esmvaltool.diag_scripts.mlr.custom_sklearn.AdvancedPipeline(*args: Any, **kwargs: Any)[source]¶
Bases:
sklearn.pipeline.Pipeline
Expand
sklearn.pipeline.Pipeline
.Attributes:
Model coefficients.
Feature importances.
Methods:
fit_target_transformer_only
(y_data, **fit_kwargs)Fit only
transform
step of of target regressor.fit_transformers_only
(x_data, y_data, ...)Fit only
transform
steps of Pipeline.transform_only
(x_data)Only perform
transform
steps of Pipeline.transform_target_only
(y_data)Only perform
transform
steps of target regressor.- property coef_¶
Model coefficients.
- Type
- property feature_importances_¶
Feature importances.
- Type
- class esmvaltool.diag_scripts.mlr.custom_sklearn.AdvancedRFE(*args: Any, **kwargs: Any)[source]¶
Bases:
sklearn.feature_selection.RFE
Expand
sklearn.feature_selection.RFE
.Methods:
fit
(x_data, y_data, **fit_kwargs)Expand
fit()
to accept kwargs.predict
(*args, **kwargs)
- class esmvaltool.diag_scripts.mlr.custom_sklearn.AdvancedRFECV(*args: Any, **kwargs: Any)[source]¶
Bases:
esmvaltool.diag_scripts.mlr.custom_sklearn.AdvancedRFE
Expand
sklearn.feature_selection.RFECV
.Methods:
fit
(x_data, y_data[, groups])Expand
fit()
to accept kwargs.predict
(*args, **kwargs)
- class esmvaltool.diag_scripts.mlr.custom_sklearn.AdvancedTransformedTargetRegressor(*args: Any, **kwargs: Any)[source]¶
Bases:
sklearn.compose.TransformedTargetRegressor
Expand
sklearn.compose.TransformedTargetRegressor
.Attributes:
Model coefficients.
Feature importances.
Methods:
fit
(x_data, y_data, **fit_kwargs)Expand
fit()
to accept kwargs.fit_transformer_only
(y_data, **fit_kwargs)Fit only
transformer
step.predict
(x_data[, always_return_1d])Expand
predict()
to accept kwargs.- property coef_¶
Model coefficients.
- Type
- property feature_importances_¶
Feature importances.
- Type
- class esmvaltool.diag_scripts.mlr.custom_sklearn.FeatureSelectionTransformer(*args: Any, **kwargs: Any)[source]¶
Bases:
sklearn.base.BaseEstimator
,sklearn.feature_selection.SelectorMixin
Transformer step of a feature selection estimator.
Methods:
fit
(*_, **__)Empty method.
- esmvaltool.diag_scripts.mlr.custom_sklearn.cross_val_score_weighted(estimator, x_data, y_data=None, groups=None, scoring=None, cv=None, n_jobs=None, verbose=0, fit_params=None, pre_dispatch='2*n_jobs', error_score=nan, sample_weights=None)[source]¶