Skip to content

Commit d11712b

Browse files
fix flake8 errors due to new pypi dependency/rule updates (#597)
1 parent b361593 commit d11712b

17 files changed

+80
-38
lines changed

.github/workflows/CI-python.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ jobs:
5353
pip install -r requirements-dev.txt
5454
- name: Install visualization dependencies
5555
shell: bash -l {0}
56-
# install scikit-learn to workaround raiwidgets dependency
5756
run: |
5857
pip install raiwidgets
5958
pip install -r requirements-vis.txt
60-
pip install --upgrade scikit-learn
6159
pip install --upgrade "shap<=0.44.0"
60+
- if: ${{ matrix.pythonVersion == '3.9' }}
61+
name: Install scikit-learn to work around raiwidgets dependency
62+
shell: bash -l {0}
63+
run: |
64+
pip install "scikit-learn==1.4.2"
6265
- name: Install test dependencies
6366
shell: bash -l {0}
6467
run: |

devops/PR-Gate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
parameters:
1919
platforms: { MacOS: macos-latest }
2020
testRunTypes: ['Notebooks']
21-
pyVersions: [3.8]
21+
pyVersions: [3.9]
2222
installationType: PipLocal
2323
envArtifactStem: $(EnvArtifactStem)
2424
envFileStem: $(EnvFileStem)

devops/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- template: templates/all-tests-job-template.yml
2424
parameters:
2525
platforms: { Linux: ubuntu-latest, MacOS: macos-latest, Windows: windows-latest }
26-
pyVersions: [3.7, 3.8]
26+
pyVersions: [3.8, 3.9]
2727
installationType: PipLocal
2828
envArtifactStem: $(EnvArtifactStem)
2929
envFileStem: $(EnvFileStem)

devops/templates/create-env-step-template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ steps:
1919

2020
- bash: |
2121
source activate ${{parameters.condaEnv}}
22-
conda install --yes --quiet --name ${{parameters.condaEnv}} numpy==1.19.5 -c conda-forge
22+
conda install --yes --quiet --name ${{parameters.condaEnv}} "numpy<1.24.0" -c conda-forge
2323
conda install --yes --quiet --name ${{parameters.condaEnv}} pytorch torchvision cpuonly -c pytorch
2424
displayName: Install Anaconda packages
2525
condition: ne(variables['Agent.OS'], 'Darwin')
2626
2727
- bash: |
2828
source activate ${{parameters.condaEnv}}
29-
conda install --yes --quiet --name ${{parameters.condaEnv}} numpy==1.19.5 -c conda-forge
29+
conda install --yes --quiet --name ${{parameters.condaEnv}} "numpy<1.24.0" -c conda-forge
3030
conda install --yes --quiet --name ${{parameters.condaEnv}} pytorch torchvision -c pytorch
3131
displayName: Install Anaconda packages on MacOS, which should not include cpuonly according to official docs
3232
condition: eq(variables['Agent.OS'], 'Darwin')

devops/templates/test-run-step-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ steps:
6969
- bash: |
7070
source activate ${{parameters.condaEnv}}
7171
pip install responsibleai
72-
pip install rai-core-flask==0.5.0
72+
pip install rai-core-flask==0.7.6
7373
pip install raiwidgets --no-deps
7474
pip install --upgrade "shap<=0.44.0"
7575
pip install -r requirements-vis.txt

notebooks/advanced-feature-transformations-explain-local.ipynb

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,14 @@
197197
"metadata": {},
198198
"outputs": [],
199199
"source": [
200+
"import sklearn\n",
200201
"from sklearn.compose import ColumnTransformer\n",
201-
"\n",
202+
"from packaging import version\n",
203+
"# for older scikit-learn versions use sparse, for newer sparse_output:\n",
204+
"if version.parse(sklearn.__version__) < version.parse('1.2'):\n",
205+
" ohe_params = {\"sparse\": False}\n",
206+
"else:\n",
207+
" ohe_params = {\"sparse_output\": False}\n",
202208
"transformations = ColumnTransformer([\n",
203209
" (\"age_fare_1\", Pipeline(steps=[\n",
204210
" ('imputer', SimpleImputer(strategy='median')),\n",
@@ -208,8 +214,8 @@
208214
" (\"age_fare_3\", many_to_many_transformer, [\"age\", \"fare\"]),\n",
209215
" (\"embarked\", Pipeline(steps=[\n",
210216
" (\"imputer\", SimpleImputer(strategy='constant', fill_value='missing')), \n",
211-
" (\"encoder\", OneHotEncoder(sparse=False))]), [\"embarked\"]),\n",
212-
" (\"sex_pclass\", OneHotEncoder(sparse=False), [\"sex\", \"pclass\"]) \n",
217+
" (\"encoder\", OneHotEncoder(**ohe_params))]), [\"embarked\"]),\n",
218+
" (\"sex_pclass\", OneHotEncoder(**ohe_params), [\"sex\", \"pclass\"]) \n",
213219
"])\n"
214220
]
215221
},
@@ -222,7 +228,14 @@
222228
"'''\n",
223229
"# Uncomment below if sklearn-pandas is not installed\n",
224230
"#!pip install sklearn-pandas\n",
231+
"import sklearn\n",
225232
"from sklearn_pandas import DataFrameMapper\n",
233+
"from packaging import version\n",
234+
"# for older scikit-learn versions use sparse, for newer sparse_output:\n",
235+
"if version.parse(sklearn.__version__) < version.parse('1.2'):\n",
236+
" ohe_params = {\"sparse\": False}\n",
237+
"else:\n",
238+
" ohe_params = {\"sparse_output\": False}\n",
226239
"\n",
227240
"# Impute, standardize the numeric features and one-hot encode the categorical features. \n",
228241
"\n",
@@ -235,8 +248,8 @@
235248
" ([\"age\", \"fare\"], many_to_many_transformer),\n",
236249
" ([\"embarked\"], Pipeline(steps=[\n",
237250
" (\"imputer\", SimpleImputer(strategy='constant', fill_value='missing')), \n",
238-
" (\"encoder\", OneHotEncoder(sparse=False))])),\n",
239-
" ([\"sex\", \"pclass\"], OneHotEncoder(sparse=False)) \n",
251+
" (\"encoder\", OneHotEncoder(**ohe_params))])),\n",
252+
" ([\"sex\", \"pclass\"], OneHotEncoder(**ohe_params)) \n",
240253
"]\n",
241254
"\n",
242255
"\n",

notebooks/simple-feature-transformations-explain-local.ipynb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,27 @@
240240
"## Fitted Transformer tuples\n",
241241
"# Uncomment below if sklearn-pandas is not installed\n",
242242
"#!pip install sklearn-pandas\n",
243+
"import sklearn\n",
243244
"from sklearn_pandas import DataFrameMapper\n",
245+
"from packaging import version\n",
246+
"# for older scikit-learn versions use sparse, for newer sparse_output:\n",
247+
"if version.parse(sklearn.__version__) < version.parse('1.2'):\n",
248+
" ohe_params = {\"sparse\": False}\n",
249+
"else:\n",
250+
" ohe_params = {\"sparse_output\": False}\n",
244251
"\n",
245252
"# Impute, standardize the numeric features and one-hot encode the categorical features. \n",
246253
"\n",
247-
"\n",
248254
"numeric_transformations = [([f], Pipeline(steps=[('imputer', SimpleImputer(strategy='median')), ('scaler', StandardScaler())])) for f in numerical]\n",
249255
"\n",
250-
"categorical_transformations = [([f], OneHotEncoder(handle_unknown='ignore', sparse=False)) for f in categorical]\n",
256+
"categorical_transformations = [([f], OneHotEncoder(handle_unknown='ignore', **ohe_params)) for f in categorical]\n",
251257
"\n",
252258
"transformations = numeric_transformations + categorical_transformations\n",
253259
"\n",
254260
"# Append classifier to preprocessing pipeline.\n",
255261
"# Now we have a full prediction pipeline.\n",
256262
"clf = Pipeline(steps=[('preprocessor', transformations),\n",
257-
" ('classifier', SVC(C = 1.0, probability=True, gamma='auto'))]) \n",
258-
"\n",
259-
"\n",
260-
"\n",
263+
" ('classifier', SVC(C = 1.0, probability=True, gamma='auto'))])\n",
261264
"'''"
262265
]
263266
},

python/docs/transformations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ In case you want to run the example with the list of fitted transformer tuples,
6464
strategy='median')), ('scaler', StandardScaler())])) for f in numerical]
6565
6666
categorical_transformations = [([f], OneHotEncoder(
67-
handle_unknown='ignore', sparse=False)) for f in categorical]
67+
handle_unknown='ignore', sparse_output=False)) for f in categorical]
6868
6969
transformations = numeric_transformations + categorical_transformations
7070

python/interpret_community/common/gpu_kmeans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from cuml import KMeans
2727
from cuml.preprocessing import SimpleImputer
2828
rapids_installed = True
29-
except BaseException:
29+
except BaseException: # noqa: B036
3030
rapids_installed = False
3131
from scipy.sparse import issparse
3232

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ hdbscan
55
lightgbm
66
xgboost
77
sklearn_pandas
8-
lime>=0.2.0.0
8+
lime>=0.2.0.0

0 commit comments

Comments
 (0)