deepluq.metrics_dl
==================

.. py:module:: deepluq.metrics_dl


Classes
-------

.. autoapisummary::

   deepluq.metrics_dl.DLMetrics


Module Contents
---------------

.. py:class:: DLMetrics

   A class to compute various Uncertainty Quantification (UQ) metrics for Deep Learning,
   including variation ratio, entropy, mutual information, total variance,
   and prediction surface using convex hulls.


   .. py:attribute:: variation_ratio
      :value: 0.0



   .. py:attribute:: shannon_entropy
      :value: 0.0



   .. py:attribute:: mutual_information
      :value: 0.0



   .. py:attribute:: total_var_center_point
      :value: 0.0



   .. py:attribute:: total_var_bounding_box
      :value: 0.0



   .. py:attribute:: prediction_surface
      :value: -1.0



   .. py:attribute:: hull
      :value: []



   .. py:attribute:: box
      :value: []



   .. py:method:: cal_vr(events)

      Compute the Variation Ratio (VR).
      Measures the proportion of non-modal class predictions.

      :param events: Model outputs or predictions.
      :type events: array-like

      :returns: Variation ratio.
      :rtype: float



   .. py:method:: calcu_entropy(events, eps=1e-15, base=2)

      Compute Shannon entropy of probabilities.

      :param events: Probability distribution.
      :type events: array-like
      :param eps: Small constant to avoid log(0).
      :type eps: float
      :param base: Logarithm base.
      :type base: int

      :returns: Shannon entropy (rounded to 5 decimals).
      :rtype: float



   .. py:method:: calcu_mi(events, eps=1e-15, base=2)

      Compute Mutual Information (MI) between predictions.

      :param events: Model probability outputs.
      :type events: array-like
      :param eps: Small constant to avoid log(0).
      :type eps: float
      :param base: Logarithm base.
      :type base: int

      :returns: Mutual information.
      :rtype: float



   .. py:method:: calcu_tv(matrix, tag)

      Compute total variance of a multi-dimensional matrix using covariance.

      :param matrix: Input data matrix.
      :type matrix: array-like
      :param tag: Either 'bounding_box' or 'center_point'.
      :type tag: str

      :returns: Total variance.
      :rtype: float



   .. py:method:: calcu_mutual_information(X, Y, Z)

      Compute mutual information between three discrete random variables X, Y, and Z.

      Reference:
          http://www.scholarpedia.org/article/Mutual_information

      :param X: Discrete random variables of shape (n_samples,).
      :type X: array-like
      :param Y: Discrete random variables of shape (n_samples,).
      :type Y: array-like
      :param Z: Discrete random variables of shape (n_samples,).
      :type Z: array-like

      :returns: Mutual information.
      :rtype: float



   .. py:method:: calcu_prediction_surface(boxes)

      Compute prediction surface by calculating convex hull areas
      from bounding box corners.

      :param boxes: List of bounding boxes [x1, y1, x2, y2].
      :type boxes: array-like

      :returns: Prediction surface area (sum of convex hulls).
      :rtype: float



