Skip to main content
`Ctrl`+`K`

# `skopt.plots`.partial_dependence

skopt.plots.partial_dependence(space, model, i, j=None, sample_points=None, n_samples=250, n_points=40, x_eval=None)

  Calculate the partial dependence for dimensions `i` and `j` with respect to the objective value, as approximated by `model`.

  The partial dependence plot shows how the value of the dimensions `i` and `j` influence the `model` predictions after “averaging out” the influence of all other dimensions.

  When `x_eval` is not `None`, the given values are used instead of random samples. In this case, `n_samples` will be ignored.

  Parameters:
    space `Space`

      The parameter space over which the minimization was performed.

    model

      Surrogate model for the objective function.

    i int

      The first dimension for which to calculate the partial dependence.

    j int, default=None

      The second dimension for which to calculate the partial dependence. To calculate the 1D partial dependence on `i` alone set `j=None`.

    sample_points np.array, shape=(n_points, n_dims), default=None

      Only used when `x_eval=None`, i.e in case partial dependence should be calculated. Randomly sampled and transformed points to use when averaging the model function at each of the `n_points` when using partial dependence.

    n_samples int, default=100

      Number of random samples to use for averaging the model function at each of the `n_points` when using partial dependence. Only used when `sample_points=None` and `x_eval=None`.

    n_points int, default=40

      Number of points at which to evaluate the partial dependence along each dimension `i` and `j`.

    x_eval list, default=None

      `x_eval` is a list of parameter values or None. In case `x_eval` is not None, the parsed dependence will be calculated using these values. Otherwise, random selected samples will be used.

  Returns:
    For 1D partial dependence:
    xi np.array

      The points at which the partial dependence was evaluated.

    yi np.array

      The value of the model at each point `xi`.

    For 2D partial dependence:
    xi np.array, shape=n_points

      The points at which the partial dependence was evaluated.

    yi np.array, shape=n_points

      The points at which the partial dependence was evaluated.

    zi np.array, shape=(n_points, n_points)

      The value of the model at each point `(xi, yi)`.

    For Categorical variables, the `xi` (and `yi` for 2D) returned are
    the indices of the variable in `Dimension.categories`.