Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebooks #584

Merged
merged 6 commits into from
May 9, 2023
Merged

Notebooks #584

merged 6 commits into from
May 9, 2023

Conversation

APJansen
Copy link
Contributor

@APJansen APJansen commented May 9, 2023

I've made all the notebooks in the tutorials folder runnable from colab, by adding at the start of each of them the code block below, only varying the paths_to_download between them. I did this rather than cloning the entire repo as the latter took the setup time from almost 1 to almost 2 minutes.

In lime_images, the example image uses a variable true_species suggesting other options, but in the data there is only the one given, so I hardcoded the colab setup to download that one.

I've tested that they all run on colab. Having some issues running some locally, mostly complaints that lime doesn't exist, but that must be something outdated in my environment, as nothing changed when it runs locally.

Also added links on the tutorial page.

running_in_colab = 'google.colab' in str(get_ipython())
if running_in_colab:
  # install dianna
  !python3 -m pip install dianna
  
  # download data used in this demo
  import os 
  base_url = 'https://github.com/raw/dianna-ai/dianna/main/tutorials/'
  paths_to_download = ['models/season_prediction_model_temp_max_binary.onnx']
  for path in paths_to_download:
      local_directory = os.path.dirname(path)
      os.makedirs(local_directory, exist_ok=True)
      !wget {base_url + path} -O {path}

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@APJansen APJansen linked an issue May 9, 2023 that may be closed by this pull request
@stefsmeets stefsmeets self-requested a review May 9, 2023 11:18
@APJansen
Copy link
Contributor Author

APJansen commented May 9, 2023

Btw, the colab buttons point to the notebooks in the main branch, so before this is merged they won't work.

@@ -13,6 +13,35 @@
"DIANNA is a Python package that brings explainable AI (XAI) to your research project. It wraps carefully selected XAI methods in a simple, uniform interface. It's built by, with and for (academic) researchers and research software engineers working on machine learning projects."
Copy link
Contributor

@stefsmeets stefsmeets May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #4.      !python3 -m pip install dianna

I think you will want to install all the notebook dependencies for dianna here (and all the other notebooks too).

!python3 -m pip install dianna[notebooks]

If this turns out to be a bottleneck, you could consider specifying the additional requirements here directly (e.g. spacy).

!python3 -m pip install dianna spacy


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point, it seems that everything we need is installed by default in Colab, but I suppose it's cleaner to add it to be sure, it doesn't take much time.

Copy link
Contributor

@stefsmeets stefsmeets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, let's see how this works when it gets merged.

I added a small comment about the table in the readme, which is a bit difficult to read.

While Github was down I was playing with wget. You can use -P to tell wget the directory to put the file you are retrieving. Saves a couple of lines :-)

    for path in paths_to_download:
        !wget {base_url + path} -P {os.path.dirname(path)}

## Colab
The tutorials can also be run directly in Google Colab, by clicking on the buttons below, or for a general demo here: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/demo.ipynb).

| modality \ method | RISE | LIME | KernelSHAP |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the table, but as a user all the Open in Colab buttons do not help me identify the notebooks. Could you change these to reflect the title or theme of the notebook?

I don't think it's possible to customize the badges (maybe https://shields.io has some). Otherwise, could you just put the link, for example:

RISE - MNIST dataset, RISE - Imagenet dataset

@APJansen APJansen merged commit c1e8c49 into main May 9, 2023
@stefsmeets stefsmeets deleted the notebooks branch May 11, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notebooks in Colab?
2 participants