validation#

Checks to ensure valid inputs for various methods.

Functions:

assert_valid_inputs(X, y[, pred_probs, ...])

Checks that X, labels, pred_probs are correctly formatted.

assert_valid_class_labels(y[, ...])

Checks that labels is properly formatted, i.e. a 1D numpy array where labels are zero-based integers (not multi-label).

assert_nonempty_input(X)

Ensures input is not None.

assert_indexing_works(X[, idx, length_X])

Ensures we can do list-based indexing into X and y.

labels_to_array(y)

Converts different types of label objects to 1D numpy array and checks their validity.

cleanlab.internal.validation.assert_valid_inputs(X, y, pred_probs=None, multi_label=False, allow_missing_classes=True, allow_one_class=False)[source]#

Checks that X, labels, pred_probs are correctly formatted.

Return type:

None

cleanlab.internal.validation.assert_valid_class_labels(y, allow_missing_classes=True, allow_one_class=False)[source]#

Checks that labels is properly formatted, i.e. a 1D numpy array where labels are zero-based integers (not multi-label).

Return type:

None

cleanlab.internal.validation.assert_nonempty_input(X)[source]#

Ensures input is not None.

Return type:

None

cleanlab.internal.validation.assert_indexing_works(X, idx=None, length_X=None)[source]#

Ensures we can do list-based indexing into X and y. length_X is an optional argument since sparse matrix X does not support: len(X) and we want this method to work for sparse X (in addition to many other types of X).

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.