marcotcr / lime

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

exp.as_pyplot_figure() renders two plots instead of one #89

Closed ianozsvald closed 6 years ago

ianozsvald commented 7 years ago

Two identical plots are generated, one is expected:

image

The above is taken from: https://github.com/ianozsvald/data_science_delivered/blob/master/ml_explain_regression_prediction.ipynb

jupyter --version
4.3.0

watermark notes the following versions:

CPython 3.6.2
IPython 6.1.0

numpy 1.13.1
matplotlib 2.0.2
sklearn 0.18.2
eli5 0.6.1
seaborn 0.8.0
lime n�
yellowbrick 0.4.2

compiler   : GCC 4.8.2 20140120 (Red Hat 4.8.2-15)
system     : Linux
release    : 4.9.8-040908-generic
machine    : x86_64
processor  : x86_64
CPU cores  : 8
interpreter: 64bit
Git hash   : d1099144f8b748e8e5aa43676f24bc8cba7204c9
AlbertoSabater commented 6 years ago

Try using a semicolon. exp.as_pyplot_figure();

marcotcr commented 6 years ago

Yeah, as_pyplot_figure displays and returns the figure, which in turn gets displayed by jupyter if you don't assign it to anything or don't add a semicolon as mentioned above.

johnidm commented 3 years ago

Another way to avoid this problem is to use the underscore to ignore the function's return value.

_ = exp.as_pyplot_figure()

I think this is more readble.

More about Role underscore in Python - https://www.datacamp.com/community/tutorials/role-underscore-python