Skip to content

Commit

Permalink
Adjust for earlier scikit-learn versions
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Wilson <[email protected]>
  • Loading branch information
BenWilson2 committed Sep 3, 2024
1 parent 5bf79c8 commit d1f5fca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions regression/steps/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def transformer_fn():
else {"feature_names_out": "one-to-one"}
)

onehot_params = (
{"sparse_output": False}
if Version(sklearn.__version__) >= Version("1.2")
else {"sparse": False}
)

return Pipeline(
steps=[
(
Expand All @@ -53,12 +59,12 @@ def transformer_fn():
transformers=[
(
"hour_encoder",
OneHotEncoder(categories="auto", sparse_output=False),
OneHotEncoder(categories="auto", **onehot_params),
["pickup_hour"],
),
(
"day_encoder",
OneHotEncoder(categories="auto", sparse_output=False),
OneHotEncoder(categories="auto", **onehot_params),
["pickup_dow"],
),
(
Expand Down

0 comments on commit d1f5fca

Please sign in to comment.