def __init__(
        self,
        train_inputs: Array,
        train_targets: Array,
        kernel: Callable[[Array], Array] = gaussian_kernel,
    ):
        """
        A Nadaraya-Watson kernel regressor.

        Parameters
        ----------
        kernel: Callable[[Array], Array]
            A kernel.
        train_inputs: Array
            Training inputs.
        train_targets: Array
            Training targets.
        """
        self.kernel = kernel

        if (train_inputs.ndim > 1) or (train_targets.ndim > 1):
            raise ValueError(
                "Both `train_inputs` and `train_targets` must be one-dimensional arrays."
            )
        if len(train_inputs) != len(train_targets):
            raise ValueError(
                "`train_inputs` and `train_targets` must have the same length."
            )
        self.train_inputs = jnp.copy(train_inputs)
        self._mean_train_targets = jnp.mean(train_targets)
        self._std_train_targets = jnp.std(train_targets)
        self.standardized_train_targets = (
            jnp.copy(train_targets) - self._mean_train_targets
        ) / self._std_train_targets

        A Nadaraya-Watson kernel regressor.

        Parameters
        ----------
        kernel: Callable[[Array], Array]
            A kernel.
        train_inputs: Array
            Training inputs.
        train_targets: Array
            Training targets.
        
fortuna/kernel_regression/nadaraya_watson.py