Skip to content

Commit

Permalink
Examples restructure (#1335)
Browse files Browse the repository at this point in the history
* Restructuring galleries

* Restructuring galleries

* Fixing read more urls

* fix plot_simple_classification_tutorial.py

* Fixing tutorials navbar

* fix git ignore
  • Loading branch information
ItayGabbay committed Apr 27, 2022
1 parent c700e58 commit f442813
Show file tree
Hide file tree
Showing 99 changed files with 110 additions and 193 deletions.
19 changes: 3 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,11 @@ docs.error.log
*MNIST*

# build folders of sphinx gallery
docs/source/examples/vision/guides/examples/
docs/source/examples/general/examples/
docs/source/examples/vision/checks/distribution/examples/
docs/source/examples/vision/checks/performance/examples/
docs/source/examples/tabular/guides/examples/
docs/source/examples/tabular/checks/distribution/examples/
docs/source/examples/tabular/checks/overview/examples/
docs/source/examples/tabular/checks/integrity/examples/
docs/source/examples/tabular/checks/methodology/examples/
docs/source/examples/tabular/checks/performance/examples/
docs/source/examples/tabular/use-cases/examples/
docs/source/examples/tabular/checks/methodology/examples/
docs/source/tutorials/tabular/examples
docs/source/tutorials/vision/examples
docs/source/examples/vision/checks/methodology/examples/
docs/source/user-guide/general/customizations/examples/
docs/source/user-guide/general/exporting_results/examples/
docs/source/tutorials/tabular/examples/
docs/source/checks_gallery/
docs/source/auto_tutorials/tabular
docs/source/auto_tutorials/vision

# build artifacts from running docs (vision and wandb export)
docs/source/tutorials/vision/*.html
Expand Down
6 changes: 3 additions & 3 deletions deepchecks/utils/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def generate_check_docs_link(check):
return ''

link_template = (
'https://docs.deepchecks.com/{version}/examples/{path}.html'
'https://docs.deepchecks.com/{version}/checks_gallery/{path}.html'
'?utm_source=display_output&utm_medium=referral'
'&utm_campaign=check_link'
)
Expand All @@ -161,13 +161,13 @@ def generate_check_docs_link(check):
# understand how link is formatted:
#
# - deepchecks.tabular.checks.integrity.StringMismatchComparison
# - https://docs.deepchecks.com/{version}/examples/tabular/checks/integrity/examples/plot_string_mismatch_comparison.html # noqa: E501 # pylint: disable=line-too-long
# - https://docs.deepchecks.com/{version}/checks_gallery/tabular/integrity/plot_string_mismatch_comparison.html # noqa: E501 # pylint: disable=line-too-long

# Remove deepchecks from the start
module_path = module_path[len('deepchecks.'):]
module_parts = module_path.split('.')
module_parts[-1] = f'plot_{module_parts[-1]}'
module_parts.insert(len(module_parts) - 1, 'examples')
module_parts.remove('checks')
url = '/'.join([*module_parts])
if deepchecks.__version__ and deepchecks.__version__ != 'dev':
version_obj: Version = Version(deepchecks.__version__)
Expand Down
2 changes: 1 addition & 1 deletion deepchecks/vision/detection_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def validate_label(self, batch):
batch
Raises
-------
------
DeepchecksValueError
If labels format is invalid
DeepchecksNotImplementedError
Expand Down
4 changes: 2 additions & 2 deletions deepchecks/vision/vision_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def validate_image_data(self, batch):
batch
Raises
-------
------
DeepchecksValueError
If the batch data doesn't fit the format after being transformed by self().
Expand Down Expand Up @@ -415,7 +415,7 @@ def validate_get_classes(self, batch):
batch
Raises
-------
------
ValidationError
If the classes data doesn't fit the format after being transformed.
"""
Expand Down
8 changes: 5 additions & 3 deletions docs/source/_templates/autosummary/check.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{# submoduletype = tabular|vision... #}
{% set submoduletype = splitname[1] %}

{% set path = getcwd() + '/source/examples/' + submoduletype + '/checks/' + checktype + '/source/plot_' + to_snake_case(objname).lower() + '.py' %}
{% set path = getcwd() + '/source/checks/' + submoduletype + '/' + checktype + '/plot_' + to_snake_case(objname).lower() + '.py' %}

{%- if path_exists(path) %}
Examples
Expand All @@ -22,14 +22,16 @@ Examples

.. only:: html

.. figure:: /examples/{{ submoduletype }}/checks/{{ checktype}}/examples/images/thumb/sphx_glr_plot_{{ to_snake_case(objname).lower() }}_thumb.png
.. figure:: /checks_gallery/{{ submoduletype }}/{{ checktype}}/images/thumb/sphx_glr_plot_{{ to_snake_case(objname).lower() }}_thumb.png
:alt: {{ objname }}

:ref:`sphx_glr_examples_{{submoduletype}}_checks_{{ checktype }}_examples_plot_{{ to_snake_case(objname).lower() }}.py`
:ref:`sphx_glr_checks_gallery_{{submoduletype}}_{{ checktype }}_plot_{{ to_snake_case(objname).lower() }}.py`

.. raw:: html

</div>
<div style="clear:both"></div>
{%- endif %}


{% endblock %}
1 change: 1 addition & 0 deletions docs/source/api/deepchecks.vision.checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ checks
:template: autosummary/check-module.rst

distribution
methodology
performance
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ Tutorials
==========

Tabular Tutorials
-----------------
=================

.. toctree::
:maxdepth: 1
:maxdepth: 3
:caption: Tabular Tutorials
:glob:

tabular/examples/plot*
tabular/index

Vision Tutorials
----------------
================

.. toctree::
:maxdepth: 1
:maxdepth: 3
:caption: Vision Tutorials
:glob:

vision/examples/plot*
vision/index
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/source/checks/tabular/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
================
Tabular Checks
================
2 changes: 2 additions & 0 deletions docs/source/checks/tabular/distribution/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Data Distribution
===================
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
training a classifier that detects which samples come from a known
distribution and defines the drift by the accuracy of this classifier. For
more information, refer to the :doc:`Whole Dataset Drift check
</examples/tabular/checks/distribution/examples/plot_whole_dataset_drift>`.
</checks_gallery/tabular/distribution/plot_whole_dataset_drift>`.
Other approaches include statistical methods aim to measure difference
between distribution of 2 given sets. We exprimented with various approaches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Change in relation between features, or covariate shift.
The difference between a :doc:`feature drift
</examples/tabular/checks/distribution/examples/plot_train_test_feature_drift>`
</checks_gallery/tabular/distribution/plot_train_test_feature_drift>`
(or univariate dataset drift) and a multivariate drift is that in the
latter the data drift occures in more that one feature.
Expand Down
2 changes: 2 additions & 0 deletions docs/source/checks/tabular/integrity/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Data Integrity
==============
3 changes: 3 additions & 0 deletions docs/source/checks/vision/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
================
Vision Checks
================
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
===================
Data Distribution
===================
===================

Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
Another, more traditional method to detect such drift would be to use statistical methods.
Such an approach is covered by several builtin check in the deepchecks.vision package, such as the
:doc:`Label Drift Check
</examples/vision/checks/distribution/examples/plot_train_test_label_drift>`
</checks_gallery/vision/distribution/plot_train_test_label_drift>`
or the :doc:`Image Dataset Drift Check
</examples/vision/checks/distribution/examples/plot_image_dataset_drift>`.
</checks_gallery/vision/distribution/plot_image_dataset_drift>`.
Run the Check on a Classification Task (MNIST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By default the checks use the built-in image properties, and it's also possible to replace the default properties
with custom ones. For the list of the built-in image properties and explanation about custom properties refer to
:doc:`vision properties </user-guide/vision/visio_properties>`.
:doc:`vision properties </user-guide/vision/vision_properties>`.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
For object detection we have default built-in label properties. For other tasks you have to define your own custom label
properties.
For the list of the built-in object detection label properties and explanation about custom properties refer to
:doc:`vision properties </user-guide/vision/visio_properties>`.
:doc:`vision properties </user-guide/vision/vision_properties>`.
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Methodology
***********
===========
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Performance
***********
===========
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class has equal probability.
================ ===================================
Similiar to the :doc:`tabular simple model comparison check
</examples/tabular/checks/performance/examples/plot_simple_model_comparison>`,
</checks_gallery/tabular/performance/plot_simple_model_comparison>`,
there is no simple model which is more "correct" to use, each gives a different baseline
to compare to, and you may experiment with the different types and see how it performs
on your data.
Expand Down
62 changes: 28 additions & 34 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@
]

redirects = {
"examples/guides/quickstart_in_5_minutes": "../../tutorials/tabular/examples/plot_quickstart_in_5_minutes.html",
"examples/guides/quickstart_in_5_minutes": "../../auto_tutorials/tabular/plot_quickstart_in_5_minutes.html",
"user-guide/key_concepts": "../user-guide/general/deepchecks_hierarchy.html",
"user-guide/when_should_you_use": "../getting-started/when_should_you_use.html",
"examples/checks/distribution/index": "../../../examples/tabular/checks/distribution/examples/index.html",
"examples/checks/distribution/train_test_feature_drift": "../../../examples/tabular/checks/distribution/examples/plot_train_test_feature_drift.html",
"examples/checks/integrity/index": "../../../examples/tabular/checks/integrity/examples/index.html",
"examples/checks/methodology/index": "../../../examples/tabular/checks/methodology/examples/index.html",
"examples/checks/overview/index": "../../../examples/tabular/checks/overview/examples/index.html",
"examples/checks/performance/index": "../../../examples/tabular/checks/performance/examples/index.html",
"user-guide/supported_models": "..//user-guide/tabular/supported_models.html",
"examples/checks/distribution/index": "../../../checks_gallery/tabular/index.html",
"examples/checks/distribution/train_test_feature_drift": "../../../checks_gallery/tabular/distribution/plot_train_test_feature_drift.html",
"examples/checks/integrity/index": "../../../checks_gallery/tabular/index.html",
"examples/checks/methodology/index": "../../../checks_gallery/tabular/index.html",
"examples/checks/overview/index": "../../../checks_gallery/tabular/index.html",
"examples/checks/performance/index": "../../../checks_gallery/tabular/index.html",
"user-guide/supported_models": "../user-guide/tabular/supported_models.html",
"examples/guides/create_a_custom_suite": "../../user-guide/general/customizations/examples/plot_create_a_custom_suite.html",
"examples/guides/export_outputs_to_wandb": "../../user-guide/general/exporting_results/examples/plot_exports_output_to_wandb.html",
"examples/guides/save_suite_result_as_html": "../../user-guide/general/exporting_results/examples/plot_save_suite_results_as_html.html",
Expand All @@ -103,36 +103,20 @@

sphinx_gallery_conf = {
"examples_dirs": [
"examples/vision/checks/distribution/source",
"examples/vision/checks/performance/source",
"examples/vision/checks/methodology/source",
# "examples/tabular/guides/source",
"examples/tabular/checks/distribution/source",
"examples/tabular/checks/overview/source",
"examples/tabular/checks/integrity/source",
"examples/tabular/checks/methodology/source",
"examples/tabular/checks/performance/source",
"checks/vision",
"checks/tabular",
"tutorials/tabular",
"tutorials/vision",
"user-guide/general/customizations",
"user-guide/general/exporting_results",
# "examples/tabular/use-cases/source",
], # path to your example scripts
"gallery_dirs": [
"examples/vision/checks/distribution/examples",
"examples/vision/checks/performance/examples",
"examples/vision/checks/methodology/examples",
# "examples/tabular/guides/examples",
"examples/tabular/checks/distribution/examples",
"examples/tabular/checks/overview/examples",
"examples/tabular/checks/integrity/examples",
"examples/tabular/checks/methodology/examples",
"examples/tabular/checks/performance/examples",
"tutorials/tabular/examples",
"tutorials/vision/examples",
"checks_gallery/vision",
"checks_gallery/tabular",
"auto_tutorials/tabular",
"auto_tutorials/vision",
"user-guide/general/customizations/examples",
"user-guide/general/exporting_results/examples",
# "examples/tabular/use-cases/examples",
], # path to where to save gallery generated output
"image_scrapers": (
"matplotlib",
Expand All @@ -141,6 +125,12 @@
"pypandoc": True,
"default_thumb_file": os.path.join(os.path.dirname(os.path.abspath(__file__)),
"_static/sphx_glr_deepchecks_icon.png"),
"doc_module": "deepchecks",
"backreferences_dir": os.path.join(PROJECT_DIR, "docs/source/api/generated/backreferences"),
"reference_url": {'deepchecks': None},
# avoid generating too many cross links
"inspect_global_variables": True,
"remove_config_comments": True,
}

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -191,6 +181,7 @@
#
# autosummary_generate = False


# If true, autosummary overwrites existing files by generated stub pages.
# Defaults to true (enabled).
#
Expand All @@ -209,12 +200,15 @@
# A dictionary of values to pass into the template engine’s context
# for autosummary stubs files.


def path_exists(path: str):
return os.path.exists(path)


def getswd(pth: str):
return os.getcwd()


autosummary_context = {
'to_snake_case': to_snake_case,
'path_exists': path_exists,
Expand Down Expand Up @@ -440,10 +434,10 @@ def linkcode_resolve(domain, info):

def get_check_example_api_reference(filepath: str) -> t.Optional[str]:
if not (
filepath.startswith("docs/source/examples/tabular/checks/")
or filepath.startswith("docs/source/examples/vision/checks/")
or filepath.startswith("examples/tabular/checks/")
or filepath.startswith("examples/vision/checks/")
filepath.startswith("docs/source/checks/tabular/")
or filepath.startswith("docs/source/checks/vision/")
or filepath.startswith("checks/tabular/")
or filepath.startswith("checks/vision/")
):
return ''

Expand Down
37 changes: 0 additions & 37 deletions docs/source/distribution/index.rst

This file was deleted.

0 comments on commit f442813

Please sign in to comment.