snorkel.utils.to_int_label_array¶
-
snorkel.utils.
to_int_label_array
(X, flatten_vector=True)[source]¶ Convert an array to a (possibly flattened) array of ints.
Cast all values to ints and possibly flatten [n, 1] arrays to [n]. This method is typically used to sanitize labels before use with analysis tools or metrics that expect 1D arrays as inputs.
- Parameters
X (
ndarray
) – An array to possibly flatten and possibly cast to intflatten_vector (
bool
) – If True, flatten array into a 1D array
- Returns
The converted array
- Return type
np.ndarray
- Raises
ValueError – Provided input could not be converted to an np.ndarray