From b6c90ccdefc5fddd6620ee62f2e79245eb5da4ed Mon Sep 17 00:00:00 2001 From: rohannallamadge Date: Sat, 7 Sep 2024 21:48:13 +0530 Subject: [PATCH] r.learn.train.py: changed sparse keyword in OneHotEncoder (#1180) Ensure scikit-learn version is at least 1.2.2 Use sparse_output instead of sparse --- src/raster/r.learn.ml2/r.learn.train/r.learn.train.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/raster/r.learn.ml2/r.learn.train/r.learn.train.py b/src/raster/r.learn.ml2/r.learn.train/r.learn.train.py index d5743404eb..014c28a316 100644 --- a/src/raster/r.learn.ml2/r.learn.train/r.learn.train.py +++ b/src/raster/r.learn.ml2/r.learn.train/r.learn.train.py @@ -445,11 +445,11 @@ def main(): try: import sklearn - if sklearn.__version__ < "0.20": - gs.fatal("Package python3-scikit-learn 0.20 or newer is not installed") + if sklearn.__version__ < "1.2.2": + gs.fatal("Package python3-scikit-learn 1.2.2 or newer is not installed") except ImportError: - gs.fatal("Package python3-scikit-learn 0.20 or newer is not installed") + gs.fatal("Package python3-scikit-learn 1.2.2 or newer is not installed") try: import pandas as pd @@ -683,7 +683,7 @@ def main(): # one-hot encoding elif norm_data is False and category_maps is not None: - enc = OneHotEncoder(handle_unknown="ignore", sparse=False) + enc = OneHotEncoder(handle_unknown="ignore", sparse_output=False) trans = ColumnTransformer( remainder="passthrough", transformers=[("onehot", enc, stack.categorical)] ) @@ -691,7 +691,7 @@ def main(): # standardization and one-hot encoding elif norm_data is True and category_maps is not None: scaler = StandardScaler() - enc = OneHotEncoder(handle_unknown="ignore", sparse=False) + enc = OneHotEncoder(handle_unknown="ignore", sparse_output=False) trans = ColumnTransformer( remainder="passthrough", transformers=[