Data Interoperability
scikit-learn Docs · نسخهٔ 5e9184e53cd3 · BSD-3-Clause
=====================
Data Interoperability
Scikit-learn handles four kinds of data for X as used in fit(X, y), fit(X), fit_transform(X) and transform(X) as well as Xt as returned by transform(X) and fit_transform(X):
array-likeobjects
In fit(X) and transform(X), array-like X is converted to a numpy ndarray by calling numpy.asarray upon them. The returned Xt of transform and fit_transform is also a numpy ndarray or it is a sparse matrix or sparse array, see next bullet.
sparse matrices <sparse matrix>and sparse arrays
Many estimators can deal with sparse X, some cannot and will raise an error. For instance, linear_model.LogisticRegression can be fit on sparse X, isotonic.IsotonicRegression can not.
Some transformers return sparse Xt from transform and fit_transform. Most often, it can be controlled by a sparse_output parameter as in preprocessing.SplineTransformer.
To control whether it returns a sparse matrix or a sparse array, use sparse_interface in config_context or set_config. This also controls whether sparse attributes are sparse matrices or sparse arrays.
- tabular data: pandas and polars dataframes
See df_output_transform.
- Array API compliant arrays
Very importantly, this includes arrays on the GPU, see array_api.
:maxdepth: 2
modules/df_output_transform modules/array_api