Package: datadetective
DataDetectiveInstallpip install -U datadetectiveHow to useDataDetective works with classifiers. It ranks the suspicious labels
given probabilies by some classification model. You can use normal
Python lists, Numpy arrays or Pandas data. Return values are in a Numpy
array or a Pandas series, the larger the value, the more suspicious are
the coresponding labels.assertdatadetective.__version__=='0.4.0'fromdatadetectiveimportsuspectlabels=pd.Series(["cat","dog","dog","cat","cat"])0    cat
1    dog
2    dog
3    cat
4    cat
dtype: objectprobas=pd.DataFrame(dict(cat=[0.5,0.4,0.3,0.2,0.1],dog=[0.5,0.6,0.7,0.8,0.9],))<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>catdog00.50.510.40.620.30.730.20.840.10.9suspect(probas,labels=labels,)datadetective.classification.estimate_noise.avg_confidence:35 [0.26666667 0.65      ]<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>errsuspected00.000000False10.183333True20.000000False30.216667True40.416667Trueresidual=suspect(probas,labels=labels,rank_method="residual",return_non_errors=False,)datadetective.classification.estimate_noise.avg_confidence:35 [0.26666667 0.65      ]<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>err10.430.840.9set_logger("INFO")confidence=suspect(probas,labels=labels,rank_method="confidence",return_non_errors=False,)datadetective.classification.estimate_noise.avg_confidence:35 [0.26666667 0.65      ]<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>errid10.18333330.21666740.416667probas.assign(labels=labels,residual=residual,confidence=confidence)<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}</style>catdoglabelsresidualconfidence00.50.5catNaNNaN10.40.6dog0.40.18333320.30.7dogNaNNaN30.20.8cat0.80.21666740.10.9cat0.90.416667docstringhelp(suspect)Help on function suspect in module datadetective.api:

suspect(...)
    Rank the suspicious labels given probas from a classifier.
    Accept Numpy arrays, Pandas dataframes and series.
    We can use interger, string or even float labels, given that
    the probability matrix's columns are indexed by the same label set.
    
    #### Args
    
    - probas (n x m matrix): probabilites for possible classes.
    
    #### KwArgs
    
    - labels (n x 1 vector): observed class labels
    - rank_method (str): `residual` or `confidence`
    - return_non_errors (bool, default = True): return all rows, including non-errors
    
    #### Returns
    
    a Pandas DataFrame including 1 index and 2 columns:
    
    - id (int): the index which is the same to the original data row index
    - err (float): the magnitude of suspiciousness, valued between [0, 1]
    - suspected (bool):  whether the data row is suspected as having a label error. This collum is returned iff return_non_errors=True.