code: def rank_classes_by_label_quality(
      labels=None,
      pred_probs=None,
      *,
      class_names=None,
      num_examples=None,
      joint=None,
      confident_joint=None,
      multi_label=False,
  ) -> pd.DataFrame:
      """
      Returns a Pandas DataFrame with all classes and three overall class label quality scores
      (details about each score are listed in the Returns parameter). By default, classes are ordered
      by "Label Quality Score", ascending, so the most problematic classes are reported first.
  
      Score values are unnormalized and may tend to be very small. What matters is their relative
      ranking across the classes.
  
      This method works by providing any one (and only one) of the following inputs:
  
      1. ``labels`` and ``pred_probs``, or
      2. ``joint`` and ``num_examples``, or
      3. ``confident_joint``
  
      Only provide **exactly one of the above input options**, do not provide a combination.
  
      Examples
      --------
      >>> from cleanlab.dataset import rank_classes_by_label_quality
      >>> from sklearn.linear_model import LogisticRegression
      >>> from sklearn.model_selection import cross_val_predict
      >>> data, labels = get_data_labels_from_dataset()
      >>> yourFavoriteModel = LogisticRegression()
      >>> pred_probs = cross_val_predict(yourFavoriteModel, data, labels, cv=3, method="predict_proba")
      >>> df = rank_classes_by_label_quality(labels=labels, pred_probs=pred_probs)
  
      **Parameters**: For parameter info, see the docstring of `~cleanlab.dataset.find_overlapping_classes`.
  
      Returns
      -------
      overall_label_quality : pd.DataFrame
          Pandas DataFrame with cols "Class Index", "Label Issues", "Inverse Label Issues",
          "Label Issues", "Inverse Label Noise", "Label Quality Score",
          with a description of each of these columns below.
          The length of the DataFrame is ``num_classes`` (one row per class).
          Noise scores are between 0 and 1, where 0 implies no label issues
          in the class. The "Label Quality Score" is also between 0 and 1 where 1 implies
          perfect quality. Columns:
  
          * *Class Index*: The index of the class in 0, 1, ..., K-1.
          * *Label Issues*: ``count(given_label = k, true_label != k)``, estimated number of examples in the dataset that are labeled as class k but should have a different label.
          * *Inverse Label Issues*: ``count(given_label != k, true_label = k)``, estimated number of examples in the dataset that should actually be labeled as class k but have been given another label.
          * *Label Noise*: ``prob(true_label != k | given_label = k)``, estimated proportion of examples in the dataset that are labeled as class k but should have a different label. For each class k: this is computed by dividing the number of examples with "Label Issues" that were labeled as class k by the total number of examples labeled as class k.
          * *Inverse Label Noise*: ``prob(given_label != k | true_label = k)``, estimated proportion of examples in the dataset that should actually be labeled as class k but have been given another label.
          * *Label Quality Score*: ``p(true_label = k | given_label = k)``. This is the proportion of examples with given label k that have been labeled correctly, i.e. ``1 - label_noise``.
  
          By default, the DataFrame is ordered by "Label Quality Score", ascending.
      """
      if multi_label:
          raise ValueError(
              "For multilabel data, please instead call:  multilabel_classification.dataset.overall_multilabel_health_score()"
          )
  
      if joint is None:
          joint = estimate_joint(
              labels=labels,
              pred_probs=pred_probs,
              confident_joint=confident_joint,
          )
      if num_examples is None:
          num_examples = _get_num_examples(labels=labels)
      given_label_noise = (
          joint.sum(axis=1) - joint.diagonal()
      )  # p(s=k) - p(s=k,y=k) = p(y!=k, s=k)
      true_label_noise = (
          joint.sum(axis=0) - joint.diagonal()
      )  # p(y=k) - p(s=k,y=k) = p(s!=k,y=k)
      given_conditional_noise = given_label_noise / joint.sum(
          axis=1
      )  # p(y!=k, s=k) / p(s=k)
      true_conditional_noise = true_label_noise / joint.sum(
          axis=0
      )  # p(s!=k, y=k) / p(y=k)
      df = pd.DataFrame(
          {
              "Class Index": np.arange(len(joint)),
              "Label Issues": (given_label_noise * num_examples)
              .round()
              .astype(int),
              "Inverse Label Issues": (true_label_noise * num_examples)
              .round()
              .astype(int),
              "Label Noise": given_conditional_noise,  # p(y!=k | s=k)
              "Inverse Label Noise": true_conditional_noise,  # p(s!=k | y=k)
              # Below could equivalently be computed as: joint.diagonal() / joint.sum(axis=1)
              "Label Quality Score": 1
              - given_conditional_noise,  # p(y=k | s=k)
          }
      )
      if class_names is not None:
          df.insert(loc=0, column="Class Name", value=class_names)
      return df.sort_values(
          by="Label Quality Score", ascending=True
      ).reset_index(drop=True)
  
file_path: cleanlab/cleanlab/dataset.py
imports: from typing import Optional, cast
  import numpy
  import pandas
  from cleanlab.count import estimate_joint, num_label_issues
label_desc: Use image node_id 1 for calling a global function with example usage: rank_classes_by_label_quality(labels, pred_probs) and returns: df