Skip to content

Commit d5a1b80

Browse files
committed
Update dependencies
1 parent 679ef14 commit d5a1b80

File tree

7 files changed

+38
-32
lines changed

7 files changed

+38
-32
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Python
2323
uses: actions/setup-python@v2
2424
with:
25-
python-version: "3.10"
25+
python-version: "3.11"
2626

2727
- name: Install dependencies
2828
run: |

orangecontrib/explain/explainer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,17 @@ def _join_shap_values(
6060
of lists with the np.ndarray for each class, when explaining regression,
6161
the result is the list of one np.ndarrays.
6262
"""
63-
if isinstance(shap_values[0], np.ndarray):
64-
# regression
63+
shape = shap_values[0].shape
64+
if len(shape) == 1 or (len(shape) == 2 and shape[0] == 1):
65+
# regression and xgb with two classes
6566
return [np.vstack(shap_values)]
6667
else:
6768
# classification
68-
return [np.vstack(s) for s in zip(*shap_values)]
69+
if len(shape) == 3:
70+
transformed = [(np.squeeze(v, axis=0)).T for v in shap_values]
71+
else:
72+
transformed = [v.T for v in shap_values]
73+
return [np.vstack(s) for s in zip(*transformed)]
6974

7075

7176
def _explain_trees(

orangecontrib/explain/inspection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import scipy.sparse as sp
66
from sklearn.inspection import partial_dependence
7+
from sklearn.utils import Tags, TargetTags
78

89
from Orange.base import Model
910
from Orange.classification import Model as ClsModel
@@ -202,11 +203,13 @@ def dummy_fit(*_, **__):
202203
model.fit = dummy_fit
203204
model.fit_ = dummy_fit
204205
if model.domain.class_var.is_discrete:
205-
model._estimator_type = "classifier"
206206
model.classes_ = np.array(model.domain.class_var.values)
207+
estimator_type = "classifier"
207208
else:
208-
model._estimator_type = "regressor"
209+
estimator_type = "regressor"
209210

211+
model.__sklearn_tags__ = lambda: Tags(estimator_type=estimator_type,
212+
target_tags=TargetTags(required=True))
210213
progress_callback(0.1)
211214

212215
dep = partial_dependence(model,

orangecontrib/explain/widgets/owice.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
create_annotated_table
2727
from Orange.widgets.utils.concurrent import TaskState, ConcurrentWidgetMixin
2828
from Orange.widgets.utils.itemmodels import VariableListModel, DomainModel
29+
from Orange.widgets.utils.multi_target import check_multiple_targets_input
2930
from Orange.widgets.utils.sql import check_sql_input
3031
from Orange.widgets.utils.widgetpreview import WidgetPreview
3132
from Orange.widgets.visualize.owdistributions import LegendItem
@@ -37,10 +38,6 @@
3738

3839
from orangecontrib.explain.inspection import individual_condition_expectation
3940
from orangewidget.utils.visual_settings_dlg import VisualSettingsDialog
40-
try:
41-
from Orange.widgets.utils.multi_target import check_multiple_targets_input
42-
except ImportError:
43-
check_multiple_targets_input = lambda f: f
4441

4542

4643
class RunnerResults(SimpleNamespace):
@@ -734,7 +731,7 @@ def _apply_feature_sorting(self):
734731
if self.order_by_importance:
735732
def compute_score(feature):
736733
values = self.__results_avgs[feature][self.target_index]
737-
return -np.sum(np.abs(values - np.mean(values)))
734+
return float(-np.sum(np.abs(values - np.mean(values))))
738735

739736
try:
740737
if self.__results_avgs is None:

orangecontrib/explain/widgets/tests/test_owpermutationimportance.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,19 @@ def test_x_label(self):
281281
self.send_signal(self.widget.Inputs.model, self.rf_cls)
282282
self.wait_until_finished()
283283
label: QGraphicsTextItem = self.widget.plot.bottom_axis.label
284-
self.assertEqual(label.toPlainText(), "Decrease in AUC ")
284+
self.assertIn("Decrease in AUC", label.toPlainText())
285285

286286
self.send_signal(self.widget.Inputs.data, self.housing)
287287
self.send_signal(self.widget.Inputs.model, self.rf_reg)
288288
self.wait_until_finished()
289289
label: QGraphicsTextItem = self.widget.plot.bottom_axis.label
290-
self.assertEqual(label.toPlainText(), "Decrease in R2 ")
290+
self.assertIn("Decrease in R2", label.toPlainText())
291291

292292
score_cb: QComboBox = self.widget._score_combo
293293
simulate.combobox_activate_item(score_cb, "MSE")
294294
self.wait_until_finished()
295295
label: QGraphicsTextItem = self.widget.plot.bottom_axis.label
296-
self.assertEqual(label.toPlainText(), "Increase in MSE ")
296+
self.assertIn("Increase in MSE", label.toPlainText())
297297

298298
@unittest.mock.patch("orangecontrib.explain.widgets."
299299
"owpermutationimportance.OWPermutationImportance.run")

setup.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,16 @@
3838
]
3939

4040
INSTALL_REQUIRES = [
41-
"AnyQt",
42-
# shap's requirement, force users for numba to get updated because compatibility
43-
# issues with numpy - completely remove this pin after october 2024
44-
"numba >=0.58",
45-
"numpy",
46-
"Orange3 >=3.36.2",
47-
"orange-canvas-core >=0.1.30",
48-
"orange-widget-base >=4.22.0",
49-
"pyqtgraph",
50-
"scipy",
51-
"shap==0.42.1",
52-
"scikit-learn>=1.3.0",
41+
"AnyQt>=0.2.0",
42+
"Orange3>=3.39.0",
43+
"orange-canvas-core>=0.2.5",
44+
"orange-widget-base>=4.26.0",
45+
"pandas>=2.2.3",
46+
"scikit-learn>=1.7.0",
47+
"scipy>=1.13.0",
48+
"pyqtgraph>=0.13.1",
49+
"numpy>=2.0.0",
50+
"shap>=0.50.0",
5351
]
5452

5553
EXTRAS_REQUIRE = {

tox.ini

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ deps =
2222
{env:PYQT_PYPI_NAME:PyQt5}=={env:PYQT_PYPI_VERSION:5.15.*}
2323
{env:WEBENGINE_PYPI_NAME:PyQtWebEngine}=={env:WEBENGINE_PYPI_VERSION:5.15.*}
2424
xgboost
25-
oldest: orange3==3.36.2
26-
oldest: orange-canvas-core==0.1.30
27-
oldest: orange-widget-base==4.22.0
28-
oldest: pandas==1.4.0
29-
oldest: scikit-learn==1.3.0
30-
oldest: scipy==1.9.0
25+
oldest: orange3==3.39.0
26+
oldest: orange-canvas-core==0.2.5
27+
oldest: orange-widget-base==4.26.0
28+
oldest: pandas~=2.2.3
29+
oldest: scikit-learn~=1.7.0
30+
oldest: scipy~=1.13.0
3131
oldest: xgboost==2.0.0
32+
oldest: pyqtgraph==0.13.1
33+
oldest: numpy~=2.0.0
34+
oldest: shap==0.50.0
3235
latest: https://github.com/biolab/orange3/archive/refs/heads/master.zip#egg=orange3
3336
latest: https://github.com/biolab/orange-canvas-core/archive/refs/heads/master.zip#egg=orange-canvas-core
3437
latest: https://github.com/biolab/orange-widget-base/archive/refs/heads/master.zip#egg=orange-widget-base

0 commit comments

Comments
 (0)