validation#
Checks to ensure valid inputs for various methods.
Functions:
|
Ensures we can do list-based indexing into |
Ensures input is not None. |
|
|
Checks that |
|
Checks that |
|
Validate multi-annotator labels |
Converts different types of label objects to 1D numpy array and checks their validity. |
- cleanlab.internal.validation.assert_indexing_works(X, idx=None, length_X=None)[source]#
Ensures we can do list-based indexing into
X
andy
.length_X
is an optional argument since sparse matrixX
does not support:len(X)
and we want this method to work for sparseX
(in addition to many other types ofX
).- Return type:
None
- cleanlab.internal.validation.assert_nonempty_input(X)[source]#
Ensures input is not None.
- Return type:
None
- cleanlab.internal.validation.assert_valid_class_labels(y, allow_missing_classes=False)[source]#
Checks that
labels
is properly formatted, i.e. a 1D array that is zero-indexed (first label is 0) with all classes present (ifallow_missing_classes is False
). Assumeslabels
is a 1D numpy array (not multi-label).- Return type:
None
- cleanlab.internal.validation.assert_valid_inputs(X, y, pred_probs=None, multi_label=False, allow_missing_classes=False)[source]#
Checks that
X
,labels
,pred_probs
are correctly formatted.- Return type:
None
- cleanlab.internal.validation.assert_valid_inputs_multiannotator(labels_multiannotator, pred_probs=None)[source]#
Validate multi-annotator labels
- Return type:
None
- cleanlab.internal.validation.labels_to_array(y)[source]#
Converts different types of label objects to 1D numpy array and checks their validity.
- Parameters:
y (
Union[LabelLike
,np.generic]
) – Labels to convert to 1D numpy array. Can be a list, numpy array, pandas Series, or pandas DataFrame.- Return type:
ndarray
- Returns:
labels_array (
np.ndarray
) – 1D numpy array of labels.