From 509c72a062a1866e4408cdba8d5ac2e24c5deb4f Mon Sep 17 00:00:00 2001 From: haraoka-screen Date: Wed, 31 Jan 2024 18:52:33 +0900 Subject: [PATCH 1/2] Fix the argument name of OneHotEncoder --- examples/CausalDataGenerator_discrete.ipynb | 36 ++++++++++----------- lingam/experimental/cdg.py | 2 +- tests/test_causal_data_generator.py | 4 +-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/CausalDataGenerator_discrete.ipynb b/examples/CausalDataGenerator_discrete.ipynb index a88115d..2dc7158 100644 --- a/examples/CausalDataGenerator_discrete.ipynb +++ b/examples/CausalDataGenerator_discrete.ipynb @@ -310,25 +310,25 @@ "text/html": [ "
Pipeline(steps=[('transformer',\n",
        "                 ColumnTransformer(transformers=[('categorical',\n",
-       "                                                  OneHotEncoder(sparse=False),\n",
+       "                                                  OneHotEncoder(sparse_output=False),\n",
        "                                                  Index(['x3'], dtype='object')),\n",
        "                                                 ('numeric', 'passthrough',\n",
        "                                                  Index(['x4'], dtype='object'))])),\n",
        "                ('estimator', LogisticRegression())])
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.
Index(['x3'], dtype='object')
OneHotEncoder(sparse_output=False)
Index(['x4'], dtype='object')
passthrough
LogisticRegression()
" ], "text/plain": [ "Pipeline(steps=[('transformer',\n", " ColumnTransformer(transformers=[('categorical',\n", - " OneHotEncoder(sparse=False),\n", + " OneHotEncoder(sparse_output=False),\n", " Index(['x3'], dtype='object')),\n", " ('numeric', 'passthrough',\n", " Index(['x4'], dtype='object'))])),\n", @@ -355,25 +355,25 @@ "text/html": [ "
Pipeline(steps=[('transformer',\n",
        "                 ColumnTransformer(transformers=[('categorical',\n",
-       "                                                  OneHotEncoder(sparse=False),\n",
+       "                                                  OneHotEncoder(sparse_output=False),\n",
        "                                                  Index(['x1', 'x3'], dtype='object')),\n",
        "                                                 ('numeric', 'passthrough',\n",
        "                                                  Index(['x4'], dtype='object'))])),\n",
        "                ('estimator', LinearRegression())])
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.
Index(['x1', 'x3'], dtype='object')
OneHotEncoder(sparse_output=False)
Index(['x4'], dtype='object')
passthrough
LinearRegression()
" ], "text/plain": [ "Pipeline(steps=[('transformer',\n", " ColumnTransformer(transformers=[('categorical',\n", - " OneHotEncoder(sparse=False),\n", + " OneHotEncoder(sparse_output=False),\n", " Index(['x1', 'x3'], dtype='object')),\n", " ('numeric', 'passthrough',\n", " Index(['x4'], dtype='object'))])),\n", @@ -482,7 +482,7 @@ "text/html": [ "
GridSearchCV(estimator=Pipeline(steps=[('transformer',\n",
        "                                        ColumnTransformer(transformers=[('categorical',\n",
-       "                                                                         OneHotEncoder(sparse=False),\n",
+       "                                                                         OneHotEncoder(sparse_output=False),\n",
        "                                                                         ['x1',\n",
        "                                                                          'x3']),\n",
        "                                                                        ('numeric',\n",
@@ -493,7 +493,7 @@
        "             param_grid={'estimator__hidden_layer_sizes': [(10, 10),\n",
        "                                                           (10, 10, 10)]})
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.
['x1', 'x3']
OneHotEncoder(sparse_output=False)
['x4']
StandardScaler()
MLPRegressor(max_iter=500)
" ], "text/plain": [ "GridSearchCV(estimator=Pipeline(steps=[('transformer',\n", " ColumnTransformer(transformers=[('categorical',\n", - " OneHotEncoder(sparse=False),\n", + " OneHotEncoder(sparse_output=False),\n", " ['x1',\n", " 'x3']),\n", " ('numeric',\n", @@ -534,7 +534,7 @@ ], "source": [ "transformers = [\n", - " (\"categorical\", OneHotEncoder(sparse=False), [\"x1\", \"x3\"]),\n", + " (\"categorical\", OneHotEncoder(sparse_output=False), [\"x1\", \"x3\"]),\n", " (\"numeric\", StandardScaler(), [\"x4\"]),\n", "]\n", "transformer = ColumnTransformer(transformers=transformers)\n", @@ -972,7 +972,7 @@ "source": [ "# make multi layer perceptron model\n", "transformers = [\n", - " (\"categorical\", OneHotEncoder(sparse=False), [\"x1\", \"x3\"]),\n", + " (\"categorical\", OneHotEncoder(sparse_output=False), [\"x1\", \"x3\"]),\n", " (\"numeric\", StandardScaler(), [\"x4\"]),\n", "]\n", "transformer = ColumnTransformer(transformers=transformers)\n", diff --git a/lingam/experimental/cdg.py b/lingam/experimental/cdg.py index a77c1ac..db4efbe 100644 --- a/lingam/experimental/cdg.py +++ b/lingam/experimental/cdg.py @@ -311,7 +311,7 @@ def _make_model(self, X, y, name, model=None): if len(categoricals) > 0: transformers = [ - ("categorical", OneHotEncoder(sparse=False), categoricals), + ("categorical", OneHotEncoder(sparse_output=False), categoricals), ("numeric", "passthrough", numerics), ] trans = ColumnTransformer(transformers=transformers) diff --git a/tests/test_causal_data_generator.py b/tests/test_causal_data_generator.py index f2eab6b..398c99d 100644 --- a/tests/test_causal_data_generator.py +++ b/tests/test_causal_data_generator.py @@ -135,7 +135,7 @@ def test_discrete(init, test_data2): # models transformers = [ - ("categorical", OneHotEncoder(sparse=False), ["x3"]), + ("categorical", OneHotEncoder(sparse_output=False), ["x3"]), ("numeric", "passthrough", ["x4"]), ] trans = ColumnTransformer(transformers=transformers) @@ -146,7 +146,7 @@ def test_discrete(init, test_data2): ]) transformers = [ - ("categorical", OneHotEncoder(sparse=False), ["x1", "x3"]), + ("categorical", OneHotEncoder(sparse_output=False), ["x1", "x3"]), ("numeric", "passthrough", ["x4"]), ] trans = ColumnTransformer(transformers=transformers) From 0cf2e692f76f38501737b4391518fc09a4c62338 Mon Sep 17 00:00:00 2001 From: haraoka-screen Date: Fri, 2 Feb 2024 14:28:18 +0900 Subject: [PATCH 2/2] Update requiremnt.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 73073b6..d641f7c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ numpy scipy -scikit-learn +scikit-learn>=1.2 graphviz statsmodels networkx