code: def kde_sklearn(
      data: FloatArray, grid: FloatArray, **kwargs: Any
  ) -> FloatArray:
      """
      Kernel Density Estimation with Scikit-learn
  
      Parameters
      ----------
      data :
          Data points used to compute a density estimator. It
          has `n x p` dimensions, representing n points and p
          variables.
      grid :
          Data points at which the desity will be estimated. It
          has `m x p` dimensions, representing m points and p
          variables.
  
      Returns
      -------
      out :
          Density estimate. Has `m x 1` dimensions
      """
      # Not core dependency
      try:
          from sklearn.neighbors import KernelDensity
      except ImportError as err:
          raise ImportError("scikit-learn is not installed") from err
      kde_skl = KernelDensity(**kwargs)
      kde_skl.fit(data)
      # score_samples() returns the log-likelihood of the samples
      log_pdf = kde_skl.score_samples(grid)
      return np.exp(log_pdf)
  
file_path: plotnine/plotnine/stats/density.py
imports: from __future__ import annotations
  import typing
  import numpy
  from .._utils import array_kind
label_desc: Use image node_id 4 for calling a global function with example usage: kde_sklearn(data, grid) and returns: np