class_docstr: CleanLearning = Machine Learning with cleaned data (even when training on messy, error-ridden data).
  
  Automated and robust learning with noisy labels using any dataset and any regression model.
  For regression tasks, this class trains a ``model`` with error-prone, noisy labels
  as if the model had been instead trained on a dataset with perfect labels.
  It achieves this by estimating which labels are noisy (you might solely use CleanLearning for this estimation)
  and then removing examples estimated to have noisy labels, such that a more robust copy of the same model can be
  trained on the remaining clean data.
  
  Parameters
  ----------
  model :
      Any regression model implementing the `sklearn estimator API <https://scikit-learn.org/stable/developers/develop.html#rolling-your-own-estimator>`_,
      defining the following functions:
  
      - ``model.fit(X, y)``
      - ``model.predict(X)``
      - ``model.score(X, y)``
  
      Default model used is `sklearn.linear_model.LinearRegression
      <https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html>`_.
  
  cv_n_folds :
      This class needs holdout predictions for every data example and if not provided,
      uses cross-validation to compute them. This argument sets the number of cross-validation
      folds used to compute out-of-sample predictions for each example in ``X``. Default is 5.
      Larger values may produce better results, but requires longer to run.
  
  n_boot :
      Number of bootstrap resampling rounds used to estimate the model's epistemic uncertainty.
      Default is 5. Larger values are expected to produce better results but require longer runtimes.
      Set as 0 to skip estimating the epistemic uncertainty and get results faster.
  
  include_aleatoric_uncertainty :
      Specifies if the aleatoric uncertainty should be estimated during label error detection.
      ``True`` by default, which is expected to produce better results but require longer runtimes.
  
  verbose :
      Controls how much output is printed. Set to ``False`` to suppress print statements. Default `False`.
  
  seed :
      Set the default state of the random number generator used to split
      the data. By default, uses ``np.random`` current random state.
class_docstr_tok: ["CleanLearning","=","Machine","Learning","with","cleaned","data","(","even","when","training","on","messy",",","error-ridden","data",")",".","Automated","and","robust","learning","with","noisy","labels","using","any","dataset","and","any","regression","model",".","For","regression","tasks",",","this","class","trains","a","``","model","``","with","error-prone",",","noisy","labels","as","if","the","model","had","been","instead","trained","on","a","dataset","with","perfect","labels",".","It","achieves","this","by","estimating","which","labels","are","noisy","(","you","might","solely","use","CleanLearning","for","this","estimation",")","and","then","removing","examples","estimated","to","have","noisy","labels",",","such","that","a","more","robust","copy","of","the","same","model","can","be","trained","on","the","remaining","clean","data",".","Parameters","--","--","--","--","--","model",":","Any","regression","model","implementing","the","`","sklearn","estimator","API","<","https",":","\/\/scikit-learn.org\/stable\/developers\/develop.html","#","rolling-your-own-estimator",">","`","_",",","defining","the","following","functions",":","-","``","model.fit","(","X",",","y",")","``","-","``","model.predict","(","X",")","``","-","``","model.score","(","X",",","y",")","``","Default","model","used","is","`","sklearn.linear_model.LinearRegression","<","https",":","\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.linear_model.LinearRegression.html",">","`","_",".","cv_n_folds",":","This","class","needs","holdout","predictions","for","every","data","example","and","if","not","provided",",","uses","cross-validation","to","compute","them",".","This","argument","sets","the","number","of","cross-validation","folds","used","to","compute","out-of-sample","predictions","for","each","example","in","``","X","``",".","Default","is","5",".","Larger","values","may","produce","better","results",",","but","requires","longer","to","run",".","n_boot",":","Number","of","bootstrap","resampling","rounds","used","to","estimate","the","model","'s","epistemic","uncertainty",".","Default","is","5",".","Larger","values","are","expected","to","produce","better","results","but","require","longer","runtimes",".","Set","as","0","to","skip","estimating","the","epistemic","uncertainty","and","get","results","faster",".","include_aleatoric_uncertainty",":","Specifies","if","the","aleatoric","uncertainty","should","be","estimated","during","label","error","detection",".","``","True","``","by","default",",","which","is","expected","to","produce","better","results","but","require","longer","runtimes",".","verbose",":","Controls","how","much","output","is","printed",".","Set","to","``","False","``","to","suppress","print","statements",".","Default","`","False","`",".","seed",":","Set","the","default","state","of","the","random","number","generator","used","to","split","the","data",".","By","default",",","uses","``","np.random","``","current","random","state","."]
docstr: Identifies potential label issues (corrupted `y`-values) in the dataset, and estimates how noisy each label is.
  
  Note: this method estimates the label issues from scratch. To access previously-estimated label issues from
  this :py:class:`CleanLearning <cleanlab.regression.learn.CleanLearning>` instance, use the
  :py:meth:`self.get_label_issues <cleanlab.regression.learn.CleanLearning.get_label_issues>` method.
  
  This is the method called to find label issues inside
  :py:meth:`CleanLearning.fit() <cleanlab.regression.learn.CleanLearning.fit>`
  and they share mostly the same parameters.
  
  Parameters
  ----------
  X :
      Data features (i.e. covariates, independent variables), typically an array of shape ``(N, ...)``,
      where N is the number of examples (sample-size).
      Your ``model``, must be able to ``fit()`` and ``predict()`` data of this format.
  
  y :
      An array of shape ``(N,)`` of noisy labels (i.e. target/response/dependant variable), where some values may be erroneous.
  
  uncertainty :
      Optional estimated uncertainty for each example. Should be passed in as a float (constant uncertainty throughout all examples),
      or a numpy array of length ``N`` (estimated uncertainty for each example).
      If not provided, this method will estimate the uncertainty as the sum of the epistemic and aleatoric uncertainty.
  
  save_space :
      If True, then returned ``label_issues_df`` will not be stored as attribute.
      This means some other methods like :py:meth:`self.get_label_issues <cleanlab.regression.learn.CleanLearning.get_label_issues>` will no longer work.
  
  coarse_search_range :
      The coarse search range to find the value of ``k``, which estimates the fraction of data which have label issues.
      More values represent a more thorough search (better expected results but longer runtimes).
  
  fine_search_size :
      Size of fine-grained search grid to find the value of ``k``, which represents our estimate of the fraction of data which have label issues.
      A higher number represents a more thorough search (better expected results but longer runtimes).
  
  
  For info about the **other parameters**, see the docstring of :py:meth:`CleanLearning.fit()
  <cleanlab.regression.learn.CleanLearning.fit>`.
  
  Returns
  -------
  label_issues_df : pd.DataFrame
      DataFrame with info about label issues for each example.
      Unless `save_space` argument is specified, same DataFrame is also stored as `self.label_issues_df` attribute accessible via
      :py:meth:`get_label_issues<cleanlab.regression.learn.CleanLearning.get_label_issues>`.
  
      Each row represents an example from our dataset and the DataFrame may contain the following columns:
  
      - *is_label_issue*: boolean mask for the entire dataset where ``True`` represents a label issue and ``False`` represents an example
        that is accurately labeled with high confidence.
      - *label_quality*: Numeric score that measures the quality of each label (how likely it is to be correct,
        with lower scores indicating potentially erroneous labels).
      - *given_label*: Values originally given for this example (same as `y` input).
      - *predicted_label*: Values predicted by the trained model.
docstr_tok: ["Identifies","potential","label","issues","(","corrupted","`","y","`","-values",")","in","the","dataset",",","and","estimates","how","noisy","each","label","is",".","Note",":","this","method","estimates","the","label","issues","from","scratch",".","To","access","previously-estimated","label","issues","from","this",":","py",":","class",":","`","CleanLearning","<","cleanlab.regression.learn.CleanLearning",">","`","instance",",","use","the",":","py",":","meth",":","`","self.get_label_issues","<","cleanlab.regression.learn.CleanLearning.get_label_issues",">","`","method",".","This","is","the","method","called","to","find","label","issues","inside",":","py",":","meth",":","`","CleanLearning.fit","(",")","<","cleanlab.regression.learn.CleanLearning.fit",">","`","and","they","share","mostly","the","same","parameters",".","Parameters","--","--","--","--","--","X",":","Data","features","(","i.e",".","covariates",",","independent","variables",")",",","typically","an","array","of","shape","``","(","N",",","...",")","``",",","where","N","is","the","number","of","examples","(","sample-size",")",".","Your","``","model","``",",","must","be","able","to","``","fit","(",")","``","and","``","predict","(",")","``","data","of","this","format",".","y",":","An","array","of","shape","``","(","N",",",")","``","of","noisy","labels","(","i.e",".","target\/response\/dependant","variable",")",",","where","some","values","may","be","erroneous",".","uncertainty",":","Optional","estimated","uncertainty","for","each","example",".","Should","be","passed","in","as","a","float","(","constant","uncertainty","throughout","all","examples",")",",","or","a","numpy","array","of","length","``","N","``","(","estimated","uncertainty","for","each","example",")",".","If","not","provided",",","this","method","will","estimate","the","uncertainty","as","the","sum","of","the","epistemic","and","aleatoric","uncertainty",".","save_space",":","If","True",",","then","returned","``","label_issues_df","``","will","not","be","stored","as","attribute",".","This","means","some","other","methods","like",":","py",":","meth",":","`","self.get_label_issues","<","cleanlab.regression.learn.CleanLearning.get_label_issues",">","`","will","no","longer","work",".","coarse_search_range",":","The","coarse","search","range","to","find","the","value","of","``","k","``",",","which","estimates","the","fraction","of","data","which","have","label","issues",".","More","values","represent","a","more","thorough","search","(","better","expected","results","but","longer","runtimes",")",".","fine_search_size",":","Size","of","fine-grained","search","grid","to","find","the","value","of","``","k","``",",","which","represents","our","estimate","of","the","fraction","of","data","which","have","label","issues",".","A","higher","number","represents","a","more","thorough","search","(","better","expected","results","but","longer","runtimes",")",".","For","info","about","the","*","*","other","parameters","*","*",",","see","the","docstring","of",":","py",":","meth",":","`","CleanLearning.fit","(",")","<","cleanlab.regression.learn.CleanLearning.fit",">","`",".","Returns","--","--","--","-","label_issues_df",":","pd.DataFrame","DataFrame","with","info","about","label","issues","for","each","example",".","Unless","`","save_space","`","argument","is","specified",",","same","DataFrame","is","also","stored","as","`","self.label_issues_df","`","attribute","accessible","via",":","py",":","meth",":","`","get_label_issues","<","cleanlab.regression.learn.CleanLearning.get_label_issues",">","`",".","Each","row","represents","an","example","from","our","dataset","and","the","DataFrame","may","contain","the","following","columns",":","-","*","is_label_issue","*",":","boolean","mask","for","the","entire","dataset","where","``","True","``","represents","a","label","issue","and","``","False","``","represents","an","example","that","is","accurately","labeled","with","high","confidence",".","-","*","label_quality","*",":","Numeric","score","that","measures","the","quality","of","each","label","(","how","likely","it","is","to","be","correct",",","with","lower","scores","indicating","potentially","erroneous","labels",")",".","-","*","given_label","*",":","Values","originally","given","for","this","example","(","same","as","`","y","`","input",")",".","-","*","predicted_label","*",":","Values","predicted","by","the","trained","model","."]
code: def find_label_issues(
      self,
      X: Union[np.ndarray, pd.DataFrame],
      y: LabelLike,
      *,
      uncertainty: Optional[Union[np.ndarray, float]] = None,
      coarse_search_range: list = [0.01, 0.05, 0.1, 0.15, 0.2],
      fine_search_size: int = 3,
      save_space: bool = False,
      model_kwargs: Optional[dict] = None,
  ) -> pd.DataFrame:
      """
      Identifies potential label issues (corrupted `y`-values) in the dataset, and estimates how noisy each label is.
  
      Note: this method estimates the label issues from scratch. To access previously-estimated label issues from
      this :py:class:`CleanLearning <cleanlab.regression.learn.CleanLearning>` instance, use the
      :py:meth:`self.get_label_issues <cleanlab.regression.learn.CleanLearning.get_label_issues>` method.
  
      This is the method called to find label issues inside
      :py:meth:`CleanLearning.fit() <cleanlab.regression.learn.CleanLearning.fit>`
      and they share mostly the same parameters.
  
      Parameters
      ----------
      X :
          Data features (i.e. covariates, independent variables), typically an array of shape ``(N, ...)``,
          where N is the number of examples (sample-size).
          Your ``model``, must be able to ``fit()`` and ``predict()`` data of this format.
  
      y :
          An array of shape ``(N,)`` of noisy labels (i.e. target/response/dependant variable), where some values may be erroneous.
  
      uncertainty :
          Optional estimated uncertainty for each example. Should be passed in as a float (constant uncertainty throughout all examples),
          or a numpy array of length ``N`` (estimated uncertainty for each example).
          If not provided, this method will estimate the uncertainty as the sum of the epistemic and aleatoric uncertainty.
  
      save_space :
          If True, then returned ``label_issues_df`` will not be stored as attribute.
          This means some other methods like :py:meth:`self.get_label_issues <cleanlab.regression.learn.CleanLearning.get_label_issues>` will no longer work.
  
      coarse_search_range :
          The coarse search range to find the value of ``k``, which estimates the fraction of data which have label issues.
          More values represent a more thorough search (better expected results but longer runtimes).
  
      fine_search_size :
          Size of fine-grained search grid to find the value of ``k``, which represents our estimate of the fraction of data which have label issues.
          A higher number represents a more thorough search (better expected results but longer runtimes).
  
  
      For info about the **other parameters**, see the docstring of :py:meth:`CleanLearning.fit()
      <cleanlab.regression.learn.CleanLearning.fit>`.
  
      Returns
      -------
      label_issues_df : pd.DataFrame
          DataFrame with info about label issues for each example.
          Unless `save_space` argument is specified, same DataFrame is also stored as `self.label_issues_df` attribute accessible via
          :py:meth:`get_label_issues<cleanlab.regression.learn.CleanLearning.get_label_issues>`.
  
          Each row represents an example from our dataset and the DataFrame may contain the following columns:
  
          - *is_label_issue*: boolean mask for the entire dataset where ``True`` represents a label issue and ``False`` represents an example
            that is accurately labeled with high confidence.
          - *label_quality*: Numeric score that measures the quality of each label (how likely it is to be correct,
            with lower scores indicating potentially erroneous labels).
          - *given_label*: Values originally given for this example (same as `y` input).
          - *predicted_label*: Values predicted by the trained model.
      """
  
      X, y = assert_valid_regression_inputs(X, y)
  
      if model_kwargs is None:
          model_kwargs = {}
  
      if self.verbose:
          print("Identifying label issues ...")
  
      # compute initial values to find best k
      initial_predictions = self._get_cv_predictions(
          X, y, model_kwargs=model_kwargs
      )
      initial_residual = initial_predictions - y
      initial_sorted_index = np.argsort(abs(initial_residual))
      initial_r2 = r2_score(y, initial_predictions)
  
      self.k, r2 = self._find_best_k(
          X=X,
          y=y,
          sorted_index=initial_sorted_index,
          coarse_search_range=coarse_search_range,
          fine_search_size=fine_search_size,
      )
  
      # check if initial r2 score (ie. not removing anything) is the best
      if initial_r2 >= r2:
          self.k = 0
  
      # get predictions using the best k
      predictions = self._get_cv_predictions(
          X,
          y,
          sorted_index=initial_sorted_index,
          k=self.k,
          model_kwargs=model_kwargs,
      )
      residual = predictions - y
  
      if uncertainty is None:
          epistemic_uncertainty = self.get_epistemic_uncertainty(
              X, y, predictions=predictions
          )
          if self.include_aleatoric_uncertainty:
              aleatoric_uncertainty = self.get_aleatoric_uncertainty(
                  X, residual
              )
          else:
              aleatoric_uncertainty = 0
          uncertainty = epistemic_uncertainty + aleatoric_uncertainty
      else:
          if isinstance(uncertainty, np.ndarray) and len(y) != len(
              uncertainty
          ):
              raise ValueError(
                  "If uncertainty is passed in as an array, it must have the same length as y."
              )
  
      label_quality_scores = np.exp(
          -abs(residual) / (uncertainty + TINY_VALUE)
      )
  
      label_issues_mask = np.zeros(len(y), dtype=bool)
      num_issues = math.ceil(len(y) * self.k)
      issues_index = np.argsort(label_quality_scores)[:num_issues]
      label_issues_mask[issues_index] = True
  
      # convert predictions to int if input is int
      if y.dtype == int:
          predictions = predictions.astype(int)
  
      label_issues_df = pd.DataFrame(
          {
              "is_label_issue": label_issues_mask,
              "label_quality": label_quality_scores,
              "given_label": y,
              "predicted_label": predictions,
          }
      )
  
      if self.verbose:
          print(
              f"Identified {np.sum(label_issues_mask)} examples with label issues."
          )
  
      if not save_space:
          if self.label_issues_df is not None and self.verbose:
              print(
                  "Overwriting previously identified label issues stored at self.label_issues_df. "
                  "self.get_label_issues() will now return the newly identified label issues. "
              )
          self.label_issues_df = label_issues_df
          self.label_issues_mask = label_issues_df[
              "is_label_issue"
          ].to_numpy()
      elif self.verbose:
          print(
              "Not storing label_issues as attributes since save_space was specified."
          )
  
      return label_issues_df
  
imports: from typing import Optional, Union, Tuple
  import inspect
  import warnings
  import math
  import numpy
  import pandas
  import sklearn.base
  from sklearn.base import BaseEstimator
  from sklearn.model_selection import KFold
  from sklearn.linear_model import LinearRegression
  from sklearn.metrics import r2_score
  from cleanlab.typing import LabelLike
  from cleanlab.internal.constants import TINY_VALUE
  from cleanlab.internal.util import train_val_split, subset_X_y
  from cleanlab.internal.regression_utils import assert_valid_regression_inputs
  from cleanlab.internal.validation import labels_to_array
label_desc: Use image node_id 5 for calling the CleanLearning obj's underlying member method code with example usage: obj.find_label_issues(X, y) and returns: label_issues_df