.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/02_data_ops/1170_sklearn_interface_learner.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite or Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_02_data_ops_1170_sklearn_interface_learner.py: .. currentmodule:: skrub .. _example_with_sklearn_interface: Turn a DataOp into a "standard" scikit-learn estimator ====================================================== When our DataOp only needs 2 inputs, X and y, we can get a learner that accepts the usual scikit-learn inputs rather than a dictionary like SkrubLearners normally do, by using :meth:`SkrubLearner.with_sklearn_interface` to obtain the learner wrapped in a :class:`XySkrubLearner`. .. GENERATED FROM PYTHON SOURCE LINES 16-23 .. code-block:: Python import skrub from skrub import selectors as s from sklearn.preprocessing import OrdinalEncoder from sklearn.ensemble import HistGradientBoostingRegressor dataset = skrub.datasets.fetch_employee_salaries() .. GENERATED FROM PYTHON SOURCE LINES 24-29 Creating an example DataOp -------------------------- We define a DataOp that does transformations similar to the :class:`TableVectorizer`. .. GENERATED FROM PYTHON SOURCE LINES 31-53 .. code-block:: Python X = skrub.var("X").skb.apply(skrub.Cleaner()) num = X.skb.select(s.numeric()).skb.set_name("num").skb.apply("passthrough") low_card = ( X.skb.select(s.string() & s.cardinality_below(30)) .skb.set_name("low_card") .skb.apply(OrdinalEncoder()) ) high_card = ( X.skb.select(s.string() - s.cardinality_below(30)) .skb.set_name("high_card") .skb.apply( skrub.StringEncoder( n_components=skrub.choose_int(10, 20, n_steps=3, name="n_components") ) ) ) datetime = ( X.skb.select(s.any_date()).skb.set_name("datetime").skb.apply(skrub.DatetimeEncoder()) ) feat = num.skb.concat([low_card, high_card, datetime], axis=1) feat .. raw:: html
Var 'X' Apply Cleaner num | Apply SelectCols low_card | Apply SelectCols high_card | Apply SelectCols datetime | Apply SelectCols Apply 'passthrough' Concat: 4 tables Apply OrdinalEncoder Apply StringEncoder Apply DatetimeEncoder


.. GENERATED FROM PYTHON SOURCE LINES 54-63 Creating & using the scikit-learn estimator ------------------------------------------- Now we make a learner and ask for the sklearn-like interface. It is used as ``tv.fit_transform(X)`` (whereas the default ``.skb.make_learner()`` behavior would require ``tv.fit_transform({'X': X})``). On any skrub learner calling :meth:`SkrubLearner.with_sklearn_interface` returns such an estimator that executes the same DataOp but exposes the scikit-learn (X, y) interface instead of the skrub one (which accepts a dictionary). .. GENERATED FROM PYTHON SOURCE LINES 65-68 .. code-block:: Python tv = feat.skb.make_learner().with_sklearn_interface() tv .. raw:: html
XySkrubLearner(learner=SkrubLearner(data_op=<Concat: 4 tables>))
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 69-71 This means our estimator can be used like any other scikit-learn transformer, for example in a scikit-learn Pipeline. .. GENERATED FROM PYTHON SOURCE LINES 73-79 .. code-block:: Python from sklearn.pipeline import Pipeline from sklearn.model_selection import cross_validate pipeline = Pipeline([("tv", tv), ("hgb", HistGradientBoostingRegressor())]) pipeline .. raw:: html
Pipeline(steps=[('tv',
                     XySkrubLearner(learner=SkrubLearner(data_op=<Concat: 4 tables>))),
                    ('hgb', HistGradientBoostingRegressor())])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 80-84 .. code-block:: Python cross_validate( pipeline, dataset.X, dataset.y, scoring="neg_mean_absolute_percentage_error" ) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) {'fit_time': array([1.97353888, 1.78285885, 1.86731505, 2.29740787, 1.78534985]), 'score_time': array([0.26279759, 0.27110457, 0.45016456, 0.27062511, 0.33524227]), 'test_score': array([-0.06755275, -0.06675774, -0.06942341, -0.07288586, -0.06517138])} .. GENERATED FROM PYTHON SOURCE LINES 85-92 It can also be used in a scikit-learn :class:`~sklearn.model_selection.GridSearchCV` or :class:`~sklearn.model_selection.RandomizedSearchCV`. :meth:`XySkrubLearner.get_param_grid` prepares for us the parameter grid that we can pass to GridSearchCV from the choices in the data op. If we provide our own grid for the other steps, skrub takes care of combining the 2 grids for us. .. GENERATED FROM PYTHON SOURCE LINES 94-107 .. code-block:: Python from sklearn.model_selection import GridSearchCV import pandas as pd hgb_grid = {"hgb__learning_rate": [0.2, 0.5]} grid_search = GridSearchCV( pipeline, tv.get_param_grid(key_prefix="tv__", outer_grid=hgb_grid) ).fit(dataset.X, dataset.y) pd.DataFrame(grid_search.cv_results_)[ ["param_hgb__learning_rate", "param_tv__0:n_components", "mean_test_score"] ].sort_values("mean_test_score", ascending=False) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) /home/circleci/project/.pixi/envs/doc/lib/python3.13/site-packages/sklearn/pipeline.py:1566: UserWarning: The following keys were passed in the environment but have no corresponding variable (or choice) in the DataOp: ['y']. This usually indicates a mis-typed variable name. To avoid this warning, remove the extra keys from the environment or add {'skrub.ignore_extra_keys': True} to the environment. You can get all the names used in a DataOp (valid keys in the env) with: list(data_op.skb.get_vars(all_named_ops=True) | data_op.skb.get_choices(named_only=True)) In a future version of skrub this warning may become an exception. res = transformer.fit_transform(X, y, **params.get("fit_transform", {})) .. raw:: html

Please enable javascript

The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").



.. GENERATED FROM PYTHON SOURCE LINES 108-113 Using the estimator in another DataOp ------------------------------------- As our table vectorizer is a normal scikit-learn estimator, it can easily be used with :meth:`.skb.apply() `. .. GENERATED FROM PYTHON SOURCE LINES 115-122 .. code-block:: Python pred = ( skrub.X() .skb.apply(tv) .skb.set_name("table_vectorizer") .skb.apply(HistGradientBoostingRegressor(), y=skrub.y()) ) pred .. raw:: html

.. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 21.432 seconds) **Estimated memory usage:** 557 MB .. _sphx_glr_download_auto_examples_02_data_ops_1170_sklearn_interface_learner.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/skrub-data/skrub/0.12.0?urlpath=lab/tree/notebooks/auto_examples/02_data_ops/1170_sklearn_interface_learner.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/02_data_ops/1170_sklearn_interface_learner.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 1170_sklearn_interface_learner.ipynb <1170_sklearn_interface_learner.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 1170_sklearn_interface_learner.py <1170_sklearn_interface_learner.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 1170_sklearn_interface_learner.zip <1170_sklearn_interface_learner.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_