marcotcr / lime

Lime: Explaining the predictions of any machine learning classifier
BSD 2-Clause "Simplified" License
11.41k stars 1.79k forks source link

Error while importing lime in a custom created pip package #650

Closed SudilHasitha closed 2 years ago

SudilHasitha commented 2 years ago

I am currently trying to develop my first python package and got this error after uploading it to test Pypi and testing it on google colab. I used Colabs because my PC memory is not sufficient.

ModuleNotFoundError Traceback (most recent call last) in ()

----> 1 import Explain_LISA_CNN_test_25 as e

1 frames /usr/local/lib/python3.7/dist-packages/Explain_LISA_CNN_test_25/init.py in ()

    6 pip.main(['install','lime'])
    7 pip.main(['install','alibi'])
----> 8 from Explain_LISA_CNN_test_25.ExplainLISA import ExplainLISA,Explanations

/usr/local/lib/python3.7/dist-packages/Explain_LISA_CNN_test_25/ExplainLISA.py in ()

  11 import matplotlib
     12 from alibi.explainers import AnchorImage
---> 13 from lime import lime_image
     14 from skimage.segmentation import mark_boundaries
     15 from alibi.explainers import IntegratedGradients

ModuleNotFoundError: No module named 'lime'

The setup.py file is as follows

from setup tools import setup, find_packages
import codecs
import os

here = os.path.abspath(os.path.dirname(__file__))

with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
    long_description = "\n" + fh.read()

VERSION = '0.0.4'
DESCRIPTION = 'description'
LONG_DESCRIPTION = 'long description'

# Setting up
setup(
    name="Explain_LISA_CNN_test_25",
    version=VERSION,
    author="myname",
    author_email="<myname@gmail.com>",
    url="https://github.com/myname/Explain_LISA_CNN",
    description=DESCRIPTION,
    long_description_content_type="text/markdown",
    long_description=long_description,
    packages=find_packages(),
    install_requires=['opencv-python', 'tensorflow', 'numpy','pandas','matplotlib','lime','shap','alibi[ray]','scikit-image'],
    keywords=['LIME', 'Integrated gradients', 'SHAP', 'Anchors', 'Explainable AI', 'XAI','CNN Explainer'],
    classifiers=[
        "Development Status :: 1 - Planning",
        "Intended Audience :: Developers",
        "Programming Language :: Python :: 3",
        "Operating System :: Unix",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: Microsoft :: Windows",
    ]
)

You can view my colab here:

https://colab.research.google.com/drive/1I5kM5t-JroWLqXKjAJt798ItmHozkfDv?usp=sharing

The git repo of the library is: https://github.com/SudilHasitha/Explain_LISA_CNN

My main intention is here to map the brain signals to interpret the predictions of the neural network. That is why I tried to convert the natural networks interpretations to frequency space. Since we all are signal processing machines (our brains) the main intention of this project is to find signals of interpreted decisions and brain waves that match them as interpretations and ultimately create some method to interpret ML decisions (CNNs).

SudilHasitha commented 2 years ago

The error is with the colab runtime. I reset the runtime and try to install the package and execute it. Then the issue was resolved.