code: def partial_dependency(
      trials,
      space,
      params=None,
      model="RandomForestRegressor",
      n_grid_points=10,
      n_samples=50,
      **kwargs,
  ):
      """
      Calculates the partial dependency of parameters in a collection of
      :class:`orion.core.worker.trial.Trial`.
  
      Parameters
      ----------
      trials: DataFrame or dict
          A dataframe of trials containing, at least, the columns 'objective' and 'id'. Or a dict
          equivalent.
  
      space: Space object
          A space object from an experiment.
  
      params: list of str, optional
          The parameters to include in the computation. All parameters are included by default.
  
      model: str
          Name of the regression model to use. Can be one of
          - AdaBoostRegressor
          - BaggingRegressor
          - ExtraTreesRegressor
          - GradientBoostingRegressor
          - RandomForestRegressor (Default)
  
      n_grid_points: int
          Number of points in the grid to compute partial dependency. Default is 10.
  
      n_samples: int
          Number of samples to randomly generate the grid used to compute the partial dependency.
          Default is 50.
  
      **kwargs
          Arguments for the regressor model.
  
      Returns
      -------
      dict
          Dictionary of DataFrames. Each combination of parameters as keys (dim1.name, dim2.name)
          and for each parameters individually (dim1.name). Columns are
          (dim1.name, dim2.name, objective) or (dim1.name, objective).
  
      """
      params = flatten_params(space, params)
  
      flattened_space = build_required_space(
          space,
          dist_requirement="linear",
          type_requirement="numerical",
          shape_requirement="flattened",
      )
  
      if trials.empty or trials.shape[0] == 0:
          return {}
  
      data = to_numpy(trials, space)
      data = flatten_numpy(data, flattened_space)
      model = train_regressor(model, data, **kwargs)
  
      data = [
          format_trials.trial_to_tuple(trial, flattened_space)
          for trial in flattened_space.sample(n_samples)
      ]
      data = pandas.DataFrame(data, columns=flattened_space.keys())
  
      partial_dependencies = {}
      for x_i, x_name in enumerate(params):
          grid, averages, stds = partial_dependency_grid(
              flattened_space, model, [x_name], data, n_grid_points
          )
          grid = reverse(flattened_space, grid)
          partial_dependencies[x_name] = (grid, averages, stds)
          for y_i in range(x_i + 1, len(params)):
              y_name = params[y_i]
              grid, averages, stds = partial_dependency_grid(
                  flattened_space,
                  model,
                  [x_name, y_name],
                  data,
                  n_grid_points,
              )
              grid = reverse(flattened_space, grid)
              partial_dependencies[(x_name, y_name)] = (
                  grid,
                  averages,
                  stds,
              )
  
      return partial_dependencies
  
file_path: orion/src/orion/analysis/partial_dependency_utils.py
imports: import copy
  import itertools
  import numpy
  import pandas
  from orion.analysis.base import flatten_numpy, flatten_params, to_numpy, train_regressor
  from orion.core.utils import format_trials
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 1 for calling a global function with example usage: partial_dependency(trials, space, params, model, n_grid_points, n_samples) and returns: partial_dependencies, dict