Skip to content

Commit

Permalink
Merge pull request #56 from mlflow/fix-transform
Browse files Browse the repository at this point in the history
Adjust for earlier scikit-learn versions
  • Loading branch information
BenWilson2 authored Sep 4, 2024
2 parents 5bf79c8 + e608f19 commit b2bf60e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 1 addition & 6 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,10 @@ disable=print-statement,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
locally-enabled,
file-ignored,
suppressed-message,
useless-suppression,
Expand Down Expand Up @@ -115,7 +110,6 @@ disable=print-statement,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
Expand Down Expand Up @@ -165,6 +159,7 @@ disable=print-statement,
not-an-iterable,
unsubscriptable-object,
unsupported-assignment-operation,
undefined-variable,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
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 b2bf60e

Please sign in to comment.