Utility Functions
Based on: Utilities for developer (opens in a new tab)
Assert
validation.assert_all_finite: Throw an error if array contains NaNs or Infs._testing.assert_allclose: quasi equality of arrays, using atolparameter
Formater / converter
validation.as_float_array: convert input to array of floatvalidation.check_array:- check that input is a 2D array. Sparse matrix and other dimensions can be optionally allowed
- call
assert_all_finite
validation.check_X_y:- check that X and y have consistent lengths
- call
check_arrayon X,column_or_1don y (usemulti_output=Truefor multilabel y)
validation.indexable: check that input arrays have consistent length and can be sliced or indexed (useful for cross-validation)- do not use
np.asanyarrayornp.atleast_2dsince it letsnp.matrixthrough (different API fromnp.array)
Random state
validation.check_random_state: randomness must be handle withnp.random.RandomStateonly
Estimators
validation.check_is_fitted: check that estimator has been fitted before calling predict or transform methodvalidation.has_fit_parameter: check that the fit method has a given parameterall_estimators: return a list of all scikit-learn estimatorsmulticlass.type_of_target: return the type of the target y among continuous, continuous-multioutput, binary, multiclass, multiclass-multioutput, multilabel-indicator or unknownmulticlass.unique_labels: Extract an ordered array of unique labels, "multiclass-multioutput" input type not allowed.
Warnings & Exceptions
utils.deprecated: decorator to mark a function or class as deprecatedexceptions.ConvergenceWarning: Custom warning to catch convergence problems (used in Lasso)