class_docstr: A single object to automatically detect all kinds of issues in datasets.
  This is how we recommend you interface with the cleanlab library if you want to audit the quality of your data and detect issues within it.
  If you have other specific goals (or are doing a less standard ML task not supported by Datalab), then consider using the other methods across the library.
  Datalab tracks intermediate state (e.g. data statistics) from certain cleanlab functions that can be re-used across other cleanlab functions for better efficiency.
  
  Parameters
  ----------
  data : Union[Dataset, pd.DataFrame, dict, list, str]
      Dataset-like object that can be converted to a Hugging Face Dataset object.
  
      It should contain the labels for all examples, identified by a
      `label_name` column in the Dataset object.
  
      Supported formats:
        - datasets.Dataset
        - pandas.DataFrame
        - dict (keys are strings, values are arrays/lists of length ``N``)
        - list (list of dictionaries that each have the same keys)
        - str
  
          - path to a local file: Text (.txt), CSV (.csv), JSON (.json)
          - or a dataset identifier on the Hugging Face Hub
  
  task : str
      The type of machine learning task that the dataset is used for.
      By default, this is set to "classification", but you can also set it to "regression" if you are working with a regression dataset.
  
  label_name : str, optional
      The name of the label column in the dataset.
  
  image_key : str, optional
      Optional key that can be specified for image datasets to point to the field containing the actual images themselves.
      If specified, additional image-specific issue types can be detected in the dataset.
      See the CleanVision package `documentation <https://cleanvision.readthedocs.io/en/latest/>`_ for descriptions of these image-specific issue types.
  
  verbosity : int, optional
      The higher the verbosity level, the more information
      Datalab prints when auditing a dataset.
      Valid values are 0 through 4. Default is 1.
  
  Examples
  --------
  >>> import datasets
  >>> from cleanlab import Datalab
  >>> data = datasets.load_dataset("glue", "sst2", split="train")
  >>> datalab = Datalab(data, label_name="label")
class_docstr_tok: ["A","single","object","to","automatically","detect","all","kinds","of","issues","in","datasets",".","This","is","how","we","recommend","you","interface","with","the","cleanlab","library","if","you","want","to","audit","the","quality","of","your","data","and","detect","issues","within","it",".","If","you","have","other","specific","goals","(","or","are","doing","a","less","standard","ML","task","not","supported","by","Datalab",")",",","then","consider","using","the","other","methods","across","the","library",".","Datalab","tracks","intermediate","state","(","e.g",".","data","statistics",")","from","certain","cleanlab","functions","that","can","be","re-used","across","other","cleanlab","functions","for","better","efficiency",".","Parameters","--","--","--","--","--","data",":","Union","[","Dataset",",","pd.DataFrame",",","dict",",","list",",","str","]","Dataset-like","object","that","can","be","converted","to","a","Hugging","Face","Dataset","object",".","It","should","contain","the","labels","for","all","examples",",","identified","by","a","`","label_name","`","column","in","the","Dataset","object",".","Supported","formats",":","-","datasets.Dataset","-","pandas.DataFrame","-","dict","(","keys","are","strings",",","values","are","arrays\/lists","of","length","``","N","``",")","-","list","(","list","of","dictionaries","that","each","have","the","same","keys",")","-","str","-","path","to","a","local","file",":","Text","(",".txt",")",",","CSV","(",".csv",")",",","JSON","(",".json",")","-","or","a","dataset","identifier","on","the","Hugging","Face","Hub","task",":","str","The","type","of","machine","learning","task","that","the","dataset","is","used","for",".","By","default",",","this","is","set","to","``","classification","''",",","but","you","can","also","set","it","to","``","regression","''","if","you","are","working","with","a","regression","dataset",".","label_name",":","str",",","optional","The","name","of","the","label","column","in","the","dataset",".","image_key",":","str",",","optional","Optional","key","that","can","be","specified","for","image","datasets","to","point","to","the","field","containing","the","actual","images","themselves",".","If","specified",",","additional","image-specific","issue","types","can","be","detected","in","the","dataset",".","See","the","CleanVision","package","`","documentation","<","https",":","\/\/cleanvision.readthedocs.io\/en\/latest\/",">","`","_","for","descriptions","of","these","image-specific","issue","types",".","verbosity",":","int",",","optional","The","higher","the","verbosity","level",",","the","more","information","Datalab","prints","when","auditing","a","dataset",".","Valid","values","are","0","through","4",".","Default","is","1",".","Examples","--","--","--","--",">",">",">","import","datasets",">",">",">","from","cleanlab","import","Datalab",">",">",">","data","=","datasets.load_dataset","(","``","glue","''",",","``","sst2","''",",","split=","''","train","''",")",">",">",">","datalab","=","Datalab","(","data",",","label_name=","''","label","''",")"]
docstr: Checks the dataset for all sorts of common issues in real-world data (in both labels and feature values).
  
  You can use Datalab to find issues in your data, utilizing *any* model you have already trained.
  This method only interacts with your model via its predictions or embeddings (and other functions thereof).
  The more of these inputs you provide, the more types of issues Datalab can detect in your dataset/labels.
  If you provide a subset of these inputs, Datalab will output what insights it can based on the limited information from your model.
  
  Note
  ----
  This method acts as a wrapper around the :py:meth:`IssueFinder.find_issues <cleanlab.datalab.internal.issue_finder.IssueFinder.find_issues>` method,
  where the core logic for issue detection is implemented.
  
  Note
  ----
  The issues are saved in the ``self.issues`` attribute, but are not returned.
  
  Parameters
  ----------
  pred_probs :
      Out-of-sample predicted class probabilities made by the model for every example in the dataset.
      To best detect label issues, provide this input obtained from the most accurate model you can produce.
  
      For classification data, this must be a 2D array with shape ``(num_examples, K)`` where ``K`` is the number of classes in the dataset.
      For regression data, this must be a 1D array with shape ``(num_examples,)`` containing the predicted value for each example.
  
  features : Optional[np.ndarray]
      Feature embeddings (vector representations) of every example in the dataset.
  
      If provided, this must be a 2D array with shape (num_examples, num_features).
  
  knn_graph :
      Sparse matrix of precomputed distances between examples in the dataset in a k nearest neighbor graph.
  
      If provided, this must be a square CSR matrix with shape ``(num_examples, num_examples)`` and ``(k*num_examples)`` non-zero entries (``k`` is the number of nearest neighbors considered for each example),
      evenly distributed across the rows.
      Each non-zero entry in this matrix is a distance between a pair of examples in the dataset. Self-distances must be omitted
      (i.e. diagonal must be all zeros, k nearest neighbors for each example do not include the example itself).
  
      This CSR format uses three 1D arrays (`data`, `indices`, `indptr`) to store a 2D matrix ``M``:
  
      - `data`: 1D array containing all the non-zero elements of matrix ``M``, listed in a row-wise fashion (but sorted within each row).
      - `indices`: 1D array storing the column indices in matrix ``M`` of these non-zero elements. Each entry in `indices` corresponds to an entry in `data`, indicating the column of ``M`` containing this entry.
      - `indptr`: 1D array indicating the start and end indices in `data` for each row of matrix ``M``. The non-zero elements of the i-th row of ``M`` are stored from ``data[indptr[i]]`` to ``data[indptr[i+1]]``.
  
      Within each row of matrix ``M`` (defined by the ranges in `indptr`), the corresponding non-zero entries (distances) of `knn_graph` must be sorted in ascending order (specifically in the segments of the `data` array that correspond to each row of ``M``). The `indices` array must also reflect this ordering, maintaining the correct column positions for these sorted distances.
  
      This type of matrix is returned by the method: `sklearn.neighbors.NearestNeighbors.kneighbors_graph <https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.NearestNeighbors.html#sklearn.neighbors.NearestNeighbors.kneighbors_graph>`_.
  
      Below is an example to illustrate:
  
      .. code-block:: python
  
          knn_graph.todense()
          # matrix([[0. , 0.3, 0.2],
          #         [0.3, 0. , 0.4],
          #         [0.2, 0.4, 0. ]])
  
          knn_graph.data
          # array([0.2, 0.3, 0.3, 0.4, 0.2, 0.4])
          # Here, 0.2 and 0.3 are the sorted distances in the first row, 0.3 and 0.4 in the second row, and so on.
  
          knn_graph.indices
          # array([2, 1, 0, 2, 0, 1])
          # Corresponding neighbor indices for the distances from the `data` array.
  
          knn_graph.indptr
          # array([0, 2, 4, 6])
          # The non-zero entries in the first row are stored from `knn_graph.data[0]` to `knn_graph.data[2]`, the second row from `knn_graph.data[2]` to `knn_graph.data[4]`, and so on.
  
      For any duplicated examples i,j whose distance is 0, there should be an *explicit* zero stored in the matrix, i.e. ``knn_graph[i,j] = 0``.
  
      If both `knn_graph` and `features` are provided, the `knn_graph` will take precendence.
      If `knn_graph` is not provided, it is constructed based on the provided `features`.
      If neither `knn_graph` nor `features` are provided, certain issue types like (near) duplicates will not be considered.
  
      .. seealso::
          See the
          `scipy.sparse.csr_matrix documentation <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html>`_
          for more details on the CSR matrix format.
  
  issue_types :
      Collection specifying which types of issues to consider in audit and any non-default parameter settings to use.
      If unspecified, a default set of issue types and recommended parameter settings is considered.
  
      This is a dictionary of dictionaries, where the keys are the issue types of interest
      and the values are dictionaries of parameter values that control how each type of issue is detected (only for advanced users).
      More specifically, the values are constructor keyword arguments passed to the corresponding ``IssueManager``,
      which is responsible for detecting the particular issue type.
  
      .. seealso::
          :py:class:`IssueManager <cleanlab.datalab.internal.issue_manager.issue_manager.IssueManager>`
  
  Examples
  --------
  
  Here are some ways to provide inputs to :py:meth:`find_issues`:
  
  - Passing ``pred_probs``:
      .. code-block:: python
  
          >>> from sklearn.linear_model import LogisticRegression
          >>> import numpy as np
          >>> from cleanlab import Datalab
          >>> X = np.array([[0, 1], [1, 1], [2, 2], [2, 0]])
          >>> y = np.array([0, 1, 1, 0])
          >>> clf = LogisticRegression(random_state=0).fit(X, y)
          >>> pred_probs = clf.predict_proba(X)
          >>> lab = Datalab(data={"X": X, "y": y}, label_name="y")
          >>> lab.find_issues(pred_probs=pred_probs)
  
  
  - Passing ``features``:
      .. code-block:: python
  
          >>> from sklearn.linear_model import LogisticRegression
          >>> from sklearn.neighbors import NearestNeighbors
          >>> import numpy as np
          >>> from cleanlab import Datalab
          >>> X = np.array([[0, 1], [1, 1], [2, 2], [2, 0]])
          >>> y = np.array([0, 1, 1, 0])
          >>> lab = Datalab(data={"X": X, "y": y}, label_name="y")
          >>> lab.find_issues(features=X)
  
  .. note::
  
      You can pass both ``pred_probs`` and ``features`` to :py:meth:`find_issues` for a more comprehensive audit.
  
  - Passing a ``knn_graph``:
      .. code-block:: python
  
          >>> from sklearn.neighbors import NearestNeighbors
          >>> import numpy as np
          >>> from cleanlab import Datalab
          >>> X = np.array([[0, 1], [1, 1], [2, 2], [2, 0]])
          >>> y = np.array([0, 1, 1, 0])
          >>> nbrs = NearestNeighbors(n_neighbors=2, metric="euclidean").fit(X)
          >>> knn_graph = nbrs.kneighbors_graph(mode="distance")
          >>> knn_graph # Pass this to Datalab
          <4x4 sparse matrix of type '<class 'numpy.float64'>'
                  with 8 stored elements in Compressed Sparse Row format>
          >>> knn_graph.toarray()  # DO NOT PASS knn_graph.toarray() to Datalab, only pass the sparse matrix itself
          array([[0.        , 1.        , 2.23606798, 0.        ],
                  [1.        , 0.        , 1.41421356, 0.        ],
                  [0.        , 1.41421356, 0.        , 2.        ],
                  [0.        , 1.41421356, 2.        , 0.        ]])
          >>> lab = Datalab(data={"X": X, "y": y}, label_name="y")
          >>> lab.find_issues(knn_graph=knn_graph)
  
  - Configuring issue types:
      Suppose you want to only consider label issues. Just pass a dictionary with the key "label" and an empty dictionary as the value (to use default label issue parameters).
  
      .. code-block:: python
  
          >>> issue_types = {"label": {}}
          >>> # lab.find_issues(pred_probs=pred_probs, issue_types=issue_types)
  
      If you are advanced user who wants greater control, you can pass keyword arguments to the issue manager that handles the label issues.
      For example, if you want to pass the keyword argument "clean_learning_kwargs"
      to the constructor of the :py:class:`LabelIssueManager <cleanlab.datalab.internal.issue_manager.label.LabelIssueManager>`, you would pass:
  
  
      .. code-block:: python
  
          >>> issue_types = {
          ...     "label": {
          ...         "clean_learning_kwargs": {
          ...             "prune_method": "prune_by_noise_rate",
          ...         },
          ...     },
          ... }
          >>> # lab.find_issues(pred_probs=pred_probs, issue_types=issue_types)
docstr_tok: ["Checks","the","dataset","for","all","sorts","of","common","issues","in","real-world","data","(","in","both","labels","and","feature","values",")",".","You","can","use","Datalab","to","find","issues","in","your","data",",","utilizing","*","any","*","model","you","have","already","trained",".","This","method","only","interacts","with","your","model","via","its","predictions","or","embeddings","(","and","other","functions","thereof",")",".","The","more","of","these","inputs","you","provide",",","the","more","types","of","issues","Datalab","can","detect","in","your","dataset\/labels",".","If","you","provide","a","subset","of","these","inputs",",","Datalab","will","output","what","insights","it","can","based","on","the","limited","information","from","your","model",".","Note","--","--","This","method","acts","as","a","wrapper","around","the",":","py",":","meth",":","`","IssueFinder.find_issues","<","cleanlab.datalab.internal.issue_finder.IssueFinder.find_issues",">","`","method",",","where","the","core","logic","for","issue","detection","is","implemented",".","Note","--","--","The","issues","are","saved","in","the","``","self.issues","``","attribute",",","but","are","not","returned",".","Parameters","--","--","--","--","--","pred_probs",":","Out-of-sample","predicted","class","probabilities","made","by","the","model","for","every","example","in","the","dataset",".","To","best","detect","label","issues",",","provide","this","input","obtained","from","the","most","accurate","model","you","can","produce",".","For","classification","data",",","this","must","be","a","2D","array","with","shape","``","(","num_examples",",","K",")","``","where","``","K","``","is","the","number","of","classes","in","the","dataset",".","For","regression","data",",","this","must","be","a","1D","array","with","shape","``","(","num_examples",",",")","``","containing","the","predicted","value","for","each","example",".","features",":","Optional","[","np.ndarray","]","Feature","embeddings","(","vector","representations",")","of","every","example","in","the","dataset",".","If","provided",",","this","must","be","a","2D","array","with","shape","(","num_examples",",","num_features",")",".","knn_graph",":","Sparse","matrix","of","precomputed","distances","between","examples","in","the","dataset","in","a","k","nearest","neighbor","graph",".","If","provided",",","this","must","be","a","square","CSR","matrix","with","shape","``","(","num_examples",",","num_examples",")","``","and","``","(","k","*","num_examples",")","``","non-zero","entries","(","``","k","``","is","the","number","of","nearest","neighbors","considered","for","each","example",")",",","evenly","distributed","across","the","rows",".","Each","non-zero","entry","in","this","matrix","is","a","distance","between","a","pair","of","examples","in","the","dataset",".","Self-distances","must","be","omitted","(","i.e",".","diagonal","must","be","all","zeros",",","k","nearest","neighbors","for","each","example","do","not","include","the","example","itself",")",".","This","CSR","format","uses","three","1D","arrays","(","`","data","`",",","`","indices","`",",","`","indptr","`",")","to","store","a","2D","matrix","``","M","``",":","-","`","data","`",":","1D","array","containing","all","the","non-zero","elements","of","matrix","``","M","``",",","listed","in","a","row-wise","fashion","(","but","sorted","within","each","row",")",".","-","`","indices","`",":","1D","array","storing","the","column","indices","in","matrix","``","M","``","of","these","non-zero","elements",".","Each","entry","in","`","indices","`","corresponds","to","an","entry","in","`","data","`",",","indicating","the","column","of","``","M","``","containing","this","entry",".","-","`","indptr","`",":","1D","array","indicating","the","start","and","end","indices","in","`","data","`","for","each","row","of","matrix","``","M","``",".","The","non-zero","elements","of","the","i-th","row","of","``","M","``","are","stored","from","``","data","[","indptr","[","i","]","]","``","to","``","data","[","indptr","[","i+1","]","]","``",".","Within","each","row","of","matrix","``","M","``","(","defined","by","the","ranges","in","`","indptr","`",")",",","the","corresponding","non-zero","entries","(","distances",")","of","`","knn_graph","`","must","be","sorted","in","ascending","order","(","specifically","in","the","segments","of","the","`","data","`","array","that","correspond","to","each","row","of","``","M","``",")",".","The","`","indices","`","array","must","also","reflect","this","ordering",",","maintaining","the","correct","column","positions","for","these","sorted","distances",".","This","type","of","matrix","is","returned","by","the","method",":","`","sklearn.neighbors.NearestNeighbors.kneighbors_graph","<","https",":","\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.neighbors.NearestNeighbors.html","#","sklearn.neighbors.NearestNeighbors.kneighbors_graph",">","`","_",".","Below","is","an","example","to","illustrate",":","..","code-block",":",":","python","knn_graph.todense","(",")","#","matrix","(","[","[","0.",",","0.3",",","0.2","]",",","#","[","0.3",",","0.",",","0.4","]",",","#","[","0.2",",","0.4",",","0",".","]","]",")","knn_graph.data","#","array","(","[","0.2",",","0.3",",","0.3",",","0.4",",","0.2",",","0.4","]",")","#","Here",",","0.2","and","0.3","are","the","sorted","distances","in","the","first","row",",","0.3","and","0.4","in","the","second","row",",","and","so","on",".","knn_graph.indices","#","array","(","[","2",",","1",",","0",",","2",",","0",",","1","]",")","#","Corresponding","neighbor","indices","for","the","distances","from","the","`","data","`","array",".","knn_graph.indptr","#","array","(","[","0",",","2",",","4",",","6","]",")","#","The","non-zero","entries","in","the","first","row","are","stored","from","`","knn_graph.data","[","0","]","`","to","`","knn_graph.data","[","2","]","`",",","the","second","row","from","`","knn_graph.data","[","2","]","`","to","`","knn_graph.data","[","4","]","`",",","and","so","on",".","For","any","duplicated","examples","i",",","j","whose","distance","is","0",",","there","should","be","an","*","explicit","*","zero","stored","in","the","matrix",",","i.e",".","``","knn_graph","[","i",",","j","]","=","0","``",".","If","both","`","knn_graph","`","and","`","features","`","are","provided",",","the","`","knn_graph","`","will","take","precendence",".","If","`","knn_graph","`","is","not","provided",",","it","is","constructed","based","on","the","provided","`","features","`",".","If","neither","`","knn_graph","`","nor","`","features","`","are","provided",",","certain","issue","types","like","(","near",")","duplicates","will","not","be","considered",".","..","seealso",":",":","See","the","`","scipy.sparse.csr_matrix","documentation","<","https",":","\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.sparse.csr_matrix.html",">","`","_","for","more","details","on","the","CSR","matrix","format",".","issue_types",":","Collection","specifying","which","types","of","issues","to","consider","in","audit","and","any","non-default","parameter","settings","to","use",".","If","unspecified",",","a","default","set","of","issue","types","and","recommended","parameter","settings","is","considered",".","This","is","a","dictionary","of","dictionaries",",","where","the","keys","are","the","issue","types","of","interest","and","the","values","are","dictionaries","of","parameter","values","that","control","how","each","type","of","issue","is","detected","(","only","for","advanced","users",")",".","More","specifically",",","the","values","are","constructor","keyword","arguments","passed","to","the","corresponding","``","IssueManager","``",",","which","is","responsible","for","detecting","the","particular","issue","type",".","..","seealso",":",":",":","py",":","class",":","`","IssueManager","<","cleanlab.datalab.internal.issue_manager.issue_manager.IssueManager",">","`","Examples","--","--","--","--","Here","are","some","ways","to","provide","inputs","to",":","py",":","meth",":","`","find_issues","`",":","-","Passing","``","pred_probs","``",":","..","code-block",":",":","python",">",">",">","from","sklearn.linear_model","import","LogisticRegression",">",">",">","import","numpy","as","np",">",">",">","from","cleanlab","import","Datalab",">",">",">","X","=","np.array","(","[","[","0",",","1","]",",","[","1",",","1","]",",","[","2",",","2","]",",","[","2",",","0","]","]",")",">",">",">","y","=","np.array","(","[","0",",","1",",","1",",","0","]",")",">",">",">","clf","=","LogisticRegression","(","random_state=0",")",".fit","(","X",",","y",")",">",">",">","pred_probs","=","clf.predict_proba","(","X",")",">",">",">","lab","=","Datalab","(","data=","{","``","X","''",":","X",",","``","y","''",":","y","}",",","label_name=","''","y","''",")",">",">",">","lab.find_issues","(","pred_probs=pred_probs",")","-","Passing","``","features","``",":","..","code-block",":",":","python",">",">",">","from","sklearn.linear_model","import","LogisticRegression",">",">",">","from","sklearn.neighbors","import","NearestNeighbors",">",">",">","import","numpy","as","np",">",">",">","from","cleanlab","import","Datalab",">",">",">","X","=","np.array","(","[","[","0",",","1","]",",","[","1",",","1","]",",","[","2",",","2","]",",","[","2",",","0","]","]",")",">",">",">","y","=","np.array","(","[","0",",","1",",","1",",","0","]",")",">",">",">","lab","=","Datalab","(","data=","{","``","X","''",":","X",",","``","y","''",":","y","}",",","label_name=","''","y","''",")",">",">",">","lab.find_issues","(","features=X",")","..","note",":",":","You","can","pass","both","``","pred_probs","``","and","``","features","``","to",":","py",":","meth",":","`","find_issues","`","for","a","more","comprehensive","audit",".","-","Passing","a","``","knn_graph","``",":","..","code-block",":",":","python",">",">",">","from","sklearn.neighbors","import","NearestNeighbors",">",">",">","import","numpy","as","np",">",">",">","from","cleanlab","import","Datalab",">",">",">","X","=","np.array","(","[","[","0",",","1","]",",","[","1",",","1","]",",","[","2",",","2","]",",","[","2",",","0","]","]",")",">",">",">","y","=","np.array","(","[","0",",","1",",","1",",","0","]",")",">",">",">","nbrs","=","NearestNeighbors","(","n_neighbors=2",",","metric=","''","euclidean","''",")",".fit","(","X",")",">",">",">","knn_graph","=","nbrs.kneighbors_graph","(","mode=","''","distance","''",")",">",">",">","knn_graph","#","Pass","this","to","Datalab","<","4x4","sparse","matrix","of","type","'","<","class","'numpy.float64","'",">","'","with","8","stored","elements","in","Compressed","Sparse","Row","format",">",">",">",">","knn_graph.toarray","(",")","#","DO","NOT","PASS","knn_graph.toarray","(",")","to","Datalab",",","only","pass","the","sparse","matrix","itself","array","(","[","[","0.",",","1.",",","2.23606798",",","0",".","]",",","[","1.",",","0.",",","1.41421356",",","0",".","]",",","[","0.",",","1.41421356",",","0.",",","2",".","]",",","[","0.",",","1.41421356",",","2.",",","0",".","]","]",")",">",">",">","lab","=","Datalab","(","data=","{","``","X","''",":","X",",","``","y","''",":","y","}",",","label_name=","''","y","''",")",">",">",">","lab.find_issues","(","knn_graph=knn_graph",")","-","Configuring","issue","types",":","Suppose","you","want","to","only","consider","label","issues",".","Just","pass","a","dictionary","with","the","key","``","label","''","and","an","empty","dictionary","as","the","value","(","to","use","default","label","issue","parameters",")",".","..","code-block",":",":","python",">",">",">","issue_types","=","{","``","label","''",":","{","}","}",">",">",">","#","lab.find_issues","(","pred_probs=pred_probs",",","issue_types=issue_types",")","If","you","are","advanced","user","who","wants","greater","control",",","you","can","pass","keyword","arguments","to","the","issue","manager","that","handles","the","label","issues",".","For","example",",","if","you","want","to","pass","the","keyword","argument","``","clean_learning_kwargs","''","to","the","constructor","of","the",":","py",":","class",":","`","LabelIssueManager","<","cleanlab.datalab.internal.issue_manager.label.LabelIssueManager",">","`",",","you","would","pass",":","..","code-block",":",":","python",">",">",">","issue_types","=","{","...","``","label","''",":","{","...","``","clean_learning_kwargs","''",":","{","...","``","prune_method","''",":","``","prune_by_noise_rate","''",",","...","}",",","...","}",",","...","}",">",">",">","#","lab.find_issues","(","pred_probs=pred_probs",",","issue_types=issue_types",")"]
code: def find_issues(
      self,
      *,
      pred_probs: Optional[np.ndarray] = None,
      features: Optional[npt.NDArray] = None,
      knn_graph: Optional[csr_matrix] = None,
      issue_types: Optional[Dict[str, Any]] = None,
  ) -> None:
      """
      Checks the dataset for all sorts of common issues in real-world data (in both labels and feature values).
  
      You can use Datalab to find issues in your data, utilizing *any* model you have already trained.
      This method only interacts with your model via its predictions or embeddings (and other functions thereof).
      The more of these inputs you provide, the more types of issues Datalab can detect in your dataset/labels.
      If you provide a subset of these inputs, Datalab will output what insights it can based on the limited information from your model.
  
      Note
      ----
      This method acts as a wrapper around the :py:meth:`IssueFinder.find_issues <cleanlab.datalab.internal.issue_finder.IssueFinder.find_issues>` method,
      where the core logic for issue detection is implemented.
  
      Note
      ----
      The issues are saved in the ``self.issues`` attribute, but are not returned.
  
      Parameters
      ----------
      pred_probs :
          Out-of-sample predicted class probabilities made by the model for every example in the dataset.
          To best detect label issues, provide this input obtained from the most accurate model you can produce.
  
          For classification data, this must be a 2D array with shape ``(num_examples, K)`` where ``K`` is the number of classes in the dataset.
          For regression data, this must be a 1D array with shape ``(num_examples,)`` containing the predicted value for each example.
  
      features : Optional[np.ndarray]
          Feature embeddings (vector representations) of every example in the dataset.
  
          If provided, this must be a 2D array with shape (num_examples, num_features).
  
      knn_graph :
          Sparse matrix of precomputed distances between examples in the dataset in a k nearest neighbor graph.
  
          If provided, this must be a square CSR matrix with shape ``(num_examples, num_examples)`` and ``(k*num_examples)`` non-zero entries (``k`` is the number of nearest neighbors considered for each example),
          evenly distributed across the rows.
          Each non-zero entry in this matrix is a distance between a pair of examples in the dataset. Self-distances must be omitted
          (i.e. diagonal must be all zeros, k nearest neighbors for each example do not include the example itself).
  
          This CSR format uses three 1D arrays (`data`, `indices`, `indptr`) to store a 2D matrix ``M``:
  
          - `data`: 1D array containing all the non-zero elements of matrix ``M``, listed in a row-wise fashion (but sorted within each row).
          - `indices`: 1D array storing the column indices in matrix ``M`` of these non-zero elements. Each entry in `indices` corresponds to an entry in `data`, indicating the column of ``M`` containing this entry.
          - `indptr`: 1D array indicating the start and end indices in `data` for each row of matrix ``M``. The non-zero elements of the i-th row of ``M`` are stored from ``data[indptr[i]]`` to ``data[indptr[i+1]]``.
  
          Within each row of matrix ``M`` (defined by the ranges in `indptr`), the corresponding non-zero entries (distances) of `knn_graph` must be sorted in ascending order (specifically in the segments of the `data` array that correspond to each row of ``M``). The `indices` array must also reflect this ordering, maintaining the correct column positions for these sorted distances.
  
          This type of matrix is returned by the method: `sklearn.neighbors.NearestNeighbors.kneighbors_graph <https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.NearestNeighbors.html#sklearn.neighbors.NearestNeighbors.kneighbors_graph>`_.
  
          Below is an example to illustrate:
  
          .. code-block:: python
  
              knn_graph.todense()
              # matrix([[0. , 0.3, 0.2],
              #         [0.3, 0. , 0.4],
              #         [0.2, 0.4, 0. ]])
  
              knn_graph.data
              # array([0.2, 0.3, 0.3, 0.4, 0.2, 0.4])
              # Here, 0.2 and 0.3 are the sorted distances in the first row, 0.3 and 0.4 in the second row, and so on.
  
              knn_graph.indices
              # array([2, 1, 0, 2, 0, 1])
              # Corresponding neighbor indices for the distances from the `data` array.
  
              knn_graph.indptr
              # array([0, 2, 4, 6])
              # The non-zero entries in the first row are stored from `knn_graph.data[0]` to `knn_graph.data[2]`, the second row from `knn_graph.data[2]` to `knn_graph.data[4]`, and so on.
  
          For any duplicated examples i,j whose distance is 0, there should be an *explicit* zero stored in the matrix, i.e. ``knn_graph[i,j] = 0``.
  
          If both `knn_graph` and `features` are provided, the `knn_graph` will take precendence.
          If `knn_graph` is not provided, it is constructed based on the provided `features`.
          If neither `knn_graph` nor `features` are provided, certain issue types like (near) duplicates will not be considered.
  
          .. seealso::
              See the
              `scipy.sparse.csr_matrix documentation <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html>`_
              for more details on the CSR matrix format.
  
      issue_types :
          Collection specifying which types of issues to consider in audit and any non-default parameter settings to use.
          If unspecified, a default set of issue types and recommended parameter settings is considered.
  
          This is a dictionary of dictionaries, where the keys are the issue types of interest
          and the values are dictionaries of parameter values that control how each type of issue is detected (only for advanced users).
          More specifically, the values are constructor keyword arguments passed to the corresponding ``IssueManager``,
          which is responsible for detecting the particular issue type.
  
          .. seealso::
              :py:class:`IssueManager <cleanlab.datalab.internal.issue_manager.issue_manager.IssueManager>`
  
      Examples
      --------
  
      Here are some ways to provide inputs to :py:meth:`find_issues`:
  
      - Passing ``pred_probs``:
          .. code-block:: python
  
              >>> from sklearn.linear_model import LogisticRegression
              >>> import numpy as np
              >>> from cleanlab import Datalab
              >>> X = np.array([[0, 1], [1, 1], [2, 2], [2, 0]])
              >>> y = np.array([0, 1, 1, 0])
              >>> clf = LogisticRegression(random_state=0).fit(X, y)
              >>> pred_probs = clf.predict_proba(X)
              >>> lab = Datalab(data={"X": X, "y": y}, label_name="y")
              >>> lab.find_issues(pred_probs=pred_probs)
  
  
      - Passing ``features``:
          .. code-block:: python
  
              >>> from sklearn.linear_model import LogisticRegression
              >>> from sklearn.neighbors import NearestNeighbors
              >>> import numpy as np
              >>> from cleanlab import Datalab
              >>> X = np.array([[0, 1], [1, 1], [2, 2], [2, 0]])
              >>> y = np.array([0, 1, 1, 0])
              >>> lab = Datalab(data={"X": X, "y": y}, label_name="y")
              >>> lab.find_issues(features=X)
  
      .. note::
  
          You can pass both ``pred_probs`` and ``features`` to :py:meth:`find_issues` for a more comprehensive audit.
  
      - Passing a ``knn_graph``:
          .. code-block:: python
  
              >>> from sklearn.neighbors import NearestNeighbors
              >>> import numpy as np
              >>> from cleanlab import Datalab
              >>> X = np.array([[0, 1], [1, 1], [2, 2], [2, 0]])
              >>> y = np.array([0, 1, 1, 0])
              >>> nbrs = NearestNeighbors(n_neighbors=2, metric="euclidean").fit(X)
              >>> knn_graph = nbrs.kneighbors_graph(mode="distance")
              >>> knn_graph # Pass this to Datalab
              <4x4 sparse matrix of type '<class 'numpy.float64'>'
                      with 8 stored elements in Compressed Sparse Row format>
              >>> knn_graph.toarray()  # DO NOT PASS knn_graph.toarray() to Datalab, only pass the sparse matrix itself
              array([[0.        , 1.        , 2.23606798, 0.        ],
                      [1.        , 0.        , 1.41421356, 0.        ],
                      [0.        , 1.41421356, 0.        , 2.        ],
                      [0.        , 1.41421356, 2.        , 0.        ]])
              >>> lab = Datalab(data={"X": X, "y": y}, label_name="y")
              >>> lab.find_issues(knn_graph=knn_graph)
  
      - Configuring issue types:
          Suppose you want to only consider label issues. Just pass a dictionary with the key "label" and an empty dictionary as the value (to use default label issue parameters).
  
          .. code-block:: python
  
              >>> issue_types = {"label": {}}
              >>> # lab.find_issues(pred_probs=pred_probs, issue_types=issue_types)
  
          If you are advanced user who wants greater control, you can pass keyword arguments to the issue manager that handles the label issues.
          For example, if you want to pass the keyword argument "clean_learning_kwargs"
          to the constructor of the :py:class:`LabelIssueManager <cleanlab.datalab.internal.issue_manager.label.LabelIssueManager>`, you would pass:
  
  
          .. code-block:: python
  
              >>> issue_types = {
              ...     "label": {
              ...         "clean_learning_kwargs": {
              ...             "prune_method": "prune_by_noise_rate",
              ...         },
              ...     },
              ... }
              >>> # lab.find_issues(pred_probs=pred_probs, issue_types=issue_types)
  
      """
  
      if issue_types is not None and not issue_types:
          warnings.warn(
              "No issue types were specified so no issues will be found in the dataset. Set `issue_types` as None to consider a default set of issues."
          )
          return None
      issue_finder = issue_finder_factory(self._imagelab)(
          datalab=self, task=self.task, verbosity=self.verbosity
      )
      issue_finder.find_issues(
          pred_probs=pred_probs,
          features=features,
          knn_graph=knn_graph,
          issue_types=issue_types,
      )
  
      if self.verbosity:
          print(
              f"\nAudit complete. {self.data_issues.issue_summary['num_issues'].sum()} issues found in the dataset."
          )
  
imports: from __future__ import annotations
  import warnings
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
  import numpy
  import pandas
  import cleanlab
  from cleanlab.datalab.internal.adapter.imagelab import create_imagelab
  from cleanlab.datalab.internal.data import Data
  from cleanlab.datalab.internal.display import _Displayer
  from cleanlab.datalab.internal.helper_factory import _DataIssuesBuilder, issue_finder_factory, report_factory
  from cleanlab.datalab.internal.issue_manager_factory import list_default_issue_types, list_possible_issue_types
  from cleanlab.datalab.internal.serialize import _Serializer
label_desc: Use image node_id 7 for calling the Datalab obj's underlying member method code with example usage: obj.find_issues() and returns: None