Skip to content

Commit

Permalink
Add plotly support to check display (#268)
Browse files Browse the repository at this point in the history
* changed check to support plotly and removed matplotlib

* Return matplotlib support

Co-authored-by: Matan Perlmutter <matan@deepchecks.com>
  • Loading branch information
matanper and Matan Perlmutter committed Dec 19, 2021
1 parent 453b0d2 commit b81d341
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
14 changes: 10 additions & 4 deletions deepchecks/base/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from IPython.core.display import display_html
from matplotlib import pyplot as plt
from pandas.io.formats.style import Styler
from plotly.basedatatypes import BaseFigure

from deepchecks.base.display_pandas import display_conditions_table, display_dataframe
from deepchecks.utils.strings import split_camel_case
Expand Down Expand Up @@ -167,7 +168,7 @@ def __init__(self, value, header: str = None, display: Any = None):
self.display = display or []

for item in self.display:
if not isinstance(item, (str, pd.DataFrame, Callable, Styler)):
if not isinstance(item, (str, pd.DataFrame, Styler, Callable, BaseFigure)):
raise DeepchecksValueError(f'Can\'t display item of type: {type(item)}')

def _ipython_display_(self):
Expand All @@ -190,9 +191,14 @@ def _ipython_display_(self):
display_dataframe(item)
elif isinstance(item, str):
display_html(item, raw=True)
elif isinstance(item, Callable):
item()
plt.show()
elif isinstance(item, BaseFigure):
item.show()
elif callable(item):
try:
item()
plt.show()
except Exception as exc:
display_html(f'Error in display {str(exc)}', raw=True)
else:
raise Exception(f'Unable to display item of type: {type(item)}')
if not self.display:
Expand Down
1 change: 0 additions & 1 deletion deepchecks/base/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from deepchecks.errors import DeepchecksValueError



__all__ = ['Dataset', 'ensure_dataframe_type']


Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ numpy>=1.19
scikit-learn>=0.24.2
ipython>=7.15.0
ipykernel>=5.3.0
seaborn>=0.11.2
matplotlib>=3.3.3
ipywidgets>=7.6.5
tqdm>=4.62.3
category-encoders>=2.3.0
scipy>=1.5.0
typing_extensions>=4.0.1
dataclasses>=0.6; python_version < '3.7'
dataclasses>=0.6; python_version < '3.7'
plotly>=5.4.0
matplotlib>=3.3.3

0 comments on commit b81d341

Please sign in to comment.