MCPcopy
hub / github.com/scikit-learn/scikit-learn / check_array

Function check_array

sklearn/utils/validation.py:733–1158  ·  view source on GitHub ↗

Input validation on an array, list, sparse matrix or similar. By default, the input is checked to be a non-empty 2D array containing only finite values. If the dtype of the array is object, attempt converting to float, raising on failure. Parameters ---------- array : objec

(
    array,
    accept_sparse=False,
    *,
    accept_large_sparse=True,
    dtype="numeric",
    order=None,
    copy=False,
    force_writeable=False,
    ensure_all_finite=True,
    ensure_non_negative=False,
    ensure_2d=True,
    allow_nd=False,
    ensure_min_samples=1,
    ensure_min_features=1,
    estimator=None,
    input_name="",
)

Source from the content-addressed store, hash-verified

731
732
733def check_array(
734 array,
735 accept_sparse=False,
736 *,
737 accept_large_sparse=True,
738 dtype="numeric",
739 order=None,
740 copy=False,
741 force_writeable=False,
742 ensure_all_finite=True,
743 ensure_non_negative=False,
744 ensure_2d=True,
745 allow_nd=False,
746 ensure_min_samples=1,
747 ensure_min_features=1,
748 estimator=None,
749 input_name="",
750):
751 """Input validation on an array, list, sparse matrix or similar.
752
753 By default, the input is checked to be a non-empty 2D array containing
754 only finite values. If the dtype of the array is object, attempt
755 converting to float, raising on failure.
756
757 Parameters
758 ----------
759 array : object
760 Input object to check / convert.
761
762 accept_sparse : str, bool or list/tuple of str, default=False
763 String[s] representing allowed sparse matrix formats, such as 'csc',
764 'csr', etc. If the input is sparse but not in the allowed format,
765 it will be converted to the first listed format. True allows the input
766 to be any format. False means that a sparse matrix input will
767 raise an error.
768
769 accept_large_sparse : bool, default=True
770 If a CSR, CSC, COO or BSR sparse matrix is supplied and accepted by
771 accept_sparse, accept_large_sparse=False will cause it to be accepted
772 only if its indices are stored with a 32-bit dtype.
773
774 .. versionadded:: 0.20
775
776 dtype : 'numeric', type, list of type or None, default='numeric'
777 Data type of result. If None, the dtype of the input is preserved.
778 If "numeric", dtype is preserved unless array.dtype is object.
779 If dtype is a list of types, conversion on the first type is only
780 performed if the dtype of the input is not in the list.
781
782 order : {'F', 'C'} or None, default=None
783 Whether an array will be forced to be fortran or c-style.
784 When order is None (default), then if copy=False, nothing is ensured
785 about the memory layout of the output array; otherwise (copy=True)
786 the memory layout of the returned array is kept as close as possible
787 to the original array.
788
789 copy : bool, default=False
790 Whether a forced copy will be triggered. If copy=False, a copy might

Callers 15

_convert_to_logitsFunction · 0.90
get_submatrixMethod · 0.90
inverse_transformMethod · 0.90
fitMethod · 0.90
isotonic_regressionFunction · 0.90
fitMethod · 0.90
_transformMethod · 0.90
_iter_test_indicesMethod · 0.90
splitMethod · 0.90
_iter_test_masksMethod · 0.90
get_n_splitsMethod · 0.90
_iter_test_masksMethod · 0.90

Calls 15

get_namespaceFunction · 0.90
_is_numpy_namespaceFunction · 0.90
_asarray_with_orderFunction · 0.90
is_pandas_df_or_seriesFunction · 0.90
_nw_into_df_or_seriesFunction · 0.85
anyFunction · 0.85
_is_pandas_string_dtypeFunction · 0.85
allFunction · 0.85
_check_estimator_nameFunction · 0.85
_ensure_no_complex_dataFunction · 0.85

Tested by 15

brute_force_neighborsFunction · 0.72
predict_probaMethod · 0.72
predictMethod · 0.72
fitMethod · 0.72
transformMethod · 0.72
predictMethod · 0.72
predictMethod · 0.72
predictMethod · 0.72
predictMethod · 0.72
predictMethod · 0.72
predictMethod · 0.72
predictMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…