sklearn.ensemble.partial_dependence.partial_dependence¶
-
sklearn.ensemble.partial_dependence.partial_dependence(gbrt, target_variables, grid=None, X=None, percentiles=(0.05, 0.95), grid_resolution=100)[source]¶ DEPRECATED: The function ensemble.partial_dependence has been deprecated in favour of inspection.partial_dependence in 0.21 and will be removed in 0.23.
Partial dependence of
target_variables.Partial dependence plots show the dependence between the joint values of the
target_variablesand the function represented by thegbrt.Read more in the User Guide.
Deprecated since version 0.21: This function was deprecated in version 0.21 in favor of
sklearn.inspection.partial_dependenceand will be removed in 0.23.- Parameters
- gbrtBaseGradientBoosting
A fitted gradient boosting model.
- target_variablesarray-like, dtype=int
The target features for which the partial dependency should be computed (size should be smaller than 3 for visual renderings).
- gridarray-like of shape (n_points, n_target_variables)
The grid of
target_variablesvalues for which the partial dependency should be evaluated (eithergridorXmust be specified).- Xarray-like of shape (n_samples, n_features)
The data on which
gbrtwas trained. It is used to generate agridfor thetarget_variables. Thegridcomprisesgrid_resolutionequally spaced points between the twopercentiles.- percentiles(low, high), default=(0.05, 0.95)
The lower and upper percentile used create the extreme values for the
grid. Only ifXis not None.- grid_resolutionint, default=100
The number of equally spaced points on the
grid.
- Returns
- pdparray, shape=(n_classes, n_points)
The partial dependence function evaluated on the
grid. For regression and binary classificationn_classes==1.- axesseq of ndarray or None
The axes with which the grid has been created or None if the grid has been given.
Examples
>>> samples = [[0, 0, 2], [1, 0, 0]] >>> labels = [0, 1] >>> from sklearn.ensemble import GradientBoostingClassifier >>> gb = GradientBoostingClassifier(random_state=0).fit(samples, labels) >>> kwargs = dict(X=samples, percentiles=(0, 1), grid_resolution=2) >>> partial_dependence(gb, [0], **kwargs) # doctest: +SKIP (array([[-4.52..., 4.52...]]), [array([ 0., 1.])])