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_variables and the function represented by the gbrt.

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_dependence and 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, shape=(n_points, len(target_variables))

The grid of target_variables values for which the partial dependency should be evaluated (either grid or X must be specified).

Xarray-like, shape=(n_samples, n_features)

The data on which gbrt was trained. It is used to generate a grid for the target_variables. The grid comprises grid_resolution equally spaced points between the two percentiles.

percentiles(low, high), default=(0.05, 0.95)

The lower and upper percentile used create the extreme values for the grid. Only if X is 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 classification n_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) 
(array([[-4.52...,  4.52...]]), [array([ 0.,  1.])])