dataeval.detectors.drift.DriftMMD ================================= .. py:class:: dataeval.detectors.drift.DriftMMD(x_ref, p_val = 0.05, x_ref_preprocessed = False, update_x_ref = None, preprocess_fn = None, sigma = None, configure_kernel_from_x_ref = True, n_permutations = 100, device = None) :term:`Maximum Mean Discrepancy (MMD) Drift Detection` algorithm using a permutation test. :param x_ref: Data used as reference distribution. :type x_ref: ArrayLike :param p_val: :term:`P-value` used for significance of the statistical test for each feature. If the FDR correction method is used, this corresponds to the acceptable q-value. :type p_val: float | None, default 0.05 :param x_ref_preprocessed: Whether the given reference data ``x_ref`` has been preprocessed yet. If ``True``, only the test data ``x`` will be preprocessed at prediction time. If ``False``, the reference data will also be preprocessed. :type x_ref_preprocessed: bool, default False :param update_x_ref: Reference data can optionally be updated using an UpdateStrategy class. Update using the last n instances seen by the detector with LastSeenUpdateStrategy or via reservoir sampling with ReservoirSamplingUpdateStrategy. :type update_x_ref: UpdateStrategy | None, default None :param preprocess_fn: Function to preprocess the data before computing the data drift metrics. Typically a :term:`dimensionality reduction` technique. :type preprocess_fn: Callable | None, default None :param sigma: Optionally set the internal GaussianRBF kernel bandwidth. Can also pass multiple bandwidth values as an array. The kernel evaluation is then averaged over those bandwidths. :type sigma: ArrayLike | None, default None :param configure_kernel_from_x_ref: Whether to already configure the kernel bandwidth from the reference data. :type configure_kernel_from_x_ref: bool, default True :param n_permutations: Number of permutations used in the permutation test. :type n_permutations: int, default 100 :param device: Device type used. The default None uses the GPU and falls back on CPU. Can be specified by passing either 'cuda', 'gpu' or 'cpu'. :type device: str | None, default None .. py:method:: predict(x) Predict whether a batch of data has drifted from the reference data and then updates reference data using specified strategy. :param x: Batch of instances. :type x: ArrayLike :returns: Output class containing the :term:`drift` prediction, :term:`p-value`, threshold and MMD metric. :rtype: DriftMMDOutput .. py:method:: score(x) Compute the :term:`p-value` resulting from a permutation test using the maximum mean discrepancy as a distance measure between the reference data and the data to be tested. :param x: Batch of instances. :type x: ArrayLike :returns: p-value obtained from the permutation test, MMD^2 between the reference and test set, and MMD^2 threshold above which :term:`drift` is flagged :rtype: tuple(float, float, float)