Skip to content

Commit

Permalink
Merge pull request #14 from audemard/main
Browse files Browse the repository at this point in the history
add functionnalities
  • Loading branch information
szczepanskiNicolas committed Feb 19, 2024
2 parents a225ef9 + df8a3b5 commit 18ccc5c
Show file tree
Hide file tree
Showing 33 changed files with 377 additions and 274 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/test_osx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: OSX tests

#on: [workflow_dispatch] #Manually
on: [push]
#on:
# workflow_run:
# workflows: ["Build"]
# types:
# - completed

jobs:
tests:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Build a wheel via an sdist
run: |
pip install build
python -m build
pip install dist/pyxai*.whl
# sudo apt install ffmpeg libsm6 libxext6 qt6-base-dev libxcb-cursor0 -y
- name: Run test suite
run: |
python3 -m pyxai -tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*.snm
*.toc
*.vrb
*.so
build
dist
requirements-download/
Expand Down
2 changes: 1 addition & 1 deletion pyxai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ contrastive_reason = explainer.contrastive_reason()
print("contrastive reason", contrastive_reason)
print("to_features:", explainer.to_features(contrastive_reason, contrastive=True))

explainer.open_GUI()
explainer.visualisation.gui()
```

<img src="https://www.cril.univ-artois.fr/pyxai/assets/figures/pyxaiGUI.png" alt="pyxai" />
Expand Down
2 changes: 1 addition & 1 deletion pyxai/examples/BT/GUI-mnist38.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_pixel_value(instance, x, y, shape):
def instance_index_to_pixel_position(i, shape):
return i // shape[0], i % shape[0]

explainer.show_on_screen(instance, minimal_tree_specific_reason,
explainer.visualisation.screen(instance, minimal_tree_specific_reason,
image={"shape": (28,28),
"dtype": numpy.uint8,
"get_pixel_value": get_pixel_value,
Expand Down
2 changes: 1 addition & 1 deletion pyxai/examples/BT/regression/builder-regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

print("extremum", explainer.extremum_range())
print("possible range", explainer.range_for_partial_instance(instance))
explainer.open_GUI()
explainer.visualisation.gui()
#sufficient_reason = explainer.sufficient_reason()
#print("sufficient: ", sufficient_reason, explainer.to_features(sufficient_reason))
#print("is implicant:", explainer.is_implicant(sufficient_reason))
2 changes: 1 addition & 1 deletion pyxai/examples/BT/regression/simple-regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
print("\ntree_specific: ", explainer.to_features(tree_specific_reason, eliminate_redundant_features=True))
print("is a tree specific", explainer.is_tree_specific_reason(tree_specific_reason))

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/DT/GUI-cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def instance_index_to_pixel_position(i, shape):
value = i - (n_pixels*2)
return value // shape[0], value % shape[0]

explainer.open_GUI(image={"shape": (32,32,3),
explainer.visualisation.gui(image={"shape": (32,32,3),
"dtype": numpy.uint8,
"get_pixel_value": get_pixel_value,
"instance_index_to_pixel_position": instance_index_to_pixel_position})
2 changes: 1 addition & 1 deletion pyxai/examples/DT/GUI-mnist38-contrastives.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_pixel_value(instance, x, y, shape):
def instance_index_to_pixel_position(i, shape):
return i // shape[0], i % shape[0]

explainer.open_GUI(image={"shape": (28,28),
explainer.visualisation.gui(image={"shape": (28,28),
"dtype": numpy.uint8,
"get_pixel_value": get_pixel_value,
"instance_index_to_pixel_position": instance_index_to_pixel_position})
Expand Down
4 changes: 2 additions & 2 deletions pyxai/examples/DT/GUI-mnist38.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def instance_index_to_pixel_position(i, shape):
return i // shape[0], i % shape[0]

# Visualization part
explainer.heat_map("heat map 1", sufficient_reasons_per_attribute)
explainer.open_GUI(image={"shape": (28,28),
explainer.visualisation.heat_map("heat map 1", sufficient_reasons_per_attribute)
explainer.visualisation.gui(image={"shape": (28,28),
"dtype": numpy.uint8,
"get_pixel_value": get_pixel_value,
"instance_index_to_pixel_position": instance_index_to_pixel_position})
2 changes: 1 addition & 1 deletion pyxai/examples/DT/builder-loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
for contrastive in contrastives:
print("contrastive:", explainer.to_features(contrastive, contrastive=True))

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/DT/builder-orchid.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
print("Minimal sufficient reasons:", minimals)
assert minimals == (-4,), "The minimal sufficient reasons are not good !"

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/DT/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
if all_are_contrastive:
print("All contrastive are ok")

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/RF/GUI-australian.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
#print("\ntree_specific: ", explainer.to_features(majoritary_reason))
#print("is majoritary:", explainer.is_majoritary_reason(majoritary_reason))

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/RF/GUI-builder-loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
print("contrastives (to_features):", explainer.to_features(contrastives[0], contrastive=True))
print("contrastives (to_features):", explainer.to_features(contrastives[1], contrastive=True))

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/RF/GUI-mnist49.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_pixel_value(instance, x, y, shape):
def instance_index_to_pixel_position(i, shape):
return i // shape[0], i % shape[0]

explainer.open_GUI(image={"shape": (28,28),
explainer.visualisation.gui(image={"shape": (28,28),
"dtype": numpy.uint8,
"get_pixel_value": get_pixel_value,
"instance_index_to_pixel_position": instance_index_to_pixel_position})
Expand Down
2 changes: 1 addition & 1 deletion pyxai/examples/RF/builder-categorical-paper.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
print("contrastive (to_features):", explainer.to_features(contrastive, contrastive=True))
print("is contrastive:", explainer.is_contrastive_reason(contrastive))

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/RF/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
if explainer.elapsed_time == Explainer.TIMEOUT: print("Time out, this is an approximation")
print("is contrastive: ", explainer.is_contrastive_reason(minimal_constrative_reason))

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/RF/theories-majoritary.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
if explainer.elapsed_time == Explainer.TIMEOUT: print("Time out, this is an approximation")
print("is contrastive: ", explainer.is_contrastive_reason(minimal_constrative_reason))

explainer.open_GUI()
explainer.visualisation.gui()
2 changes: 1 addition & 1 deletion pyxai/examples/RF/theories-types-file.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
features = explainer.to_features(majoritary_reason)
#print("features majoritary:", features)

explainer.open_GUI()
explainer.visualisation.gui()

4 changes: 3 additions & 1 deletion pyxai/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def main():
["sources/solvers/GREEDY/src/bt_wrapper.cc", "sources/solvers/GREEDY/src/Explainer.cc", "sources/solvers/GREEDY/src/Tree.cc",
"sources/solvers/GREEDY/src/Node.cc", "sources/solvers/GREEDY/src/bcp/ParserDimacs.cc", "sources/solvers/GREEDY/src/bcp/Problem.cc",
"sources/solvers/GREEDY/src/bcp/ProblemTypes.cc", "sources/solvers/GREEDY/src/bcp/Propagator.cc"],
language="c++")])
language="c++",
extra_compile_args=["-std=c++11"]
)])


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 18ccc5c

Please sign in to comment.