.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "checks_gallery/tabular/data_integrity/plot_conflicting_labels.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_checks_gallery_tabular_data_integrity_plot_conflicting_labels.py: .. _plot_tabular_conflicting_labels: Conflicting Labels ****************** This notebooks provides an overview for using and understanding the conflicting labels check. **Structure:** * `What are Conflicting Labels? <#what-are-conflicting-labels>`__ * `Load Data <#load-data>`__ * `Run the Check <#run-the-check>`__ * `Define a Condition <#define-a-condition>`__ What are Conflicting Labels? ============================ The check searches for identical samples with different labels. This can occur due to either mislabeled data, or when the data collected is missing features necessary to separate the labels. If the data is mislabled, it can confuse the model and can result in lower performance of the model. .. GENERATED FROM PYTHON SOURCE LINES 24-27 .. code-block:: default import pandas as pd from deepchecks.tabular import Dataset .. GENERATED FROM PYTHON SOURCE LINES 28-31 .. code-block:: default from deepchecks.tabular.checks import ConflictingLabels from deepchecks.tabular.datasets.classification.phishing import load_data .. GENERATED FROM PYTHON SOURCE LINES 32-34 Load Data ========= .. GENERATED FROM PYTHON SOURCE LINES 34-39 .. code-block:: default phishing_dataframe = load_data(as_train_test=False, data_format='Dataframe') phishing_dataset = Dataset(phishing_dataframe, label='target', features=['urlLength', 'numDigits', 'numParams', 'num_%20', 'num_@', 'bodyLength', 'numTitles', 'numImages', 'numLinks', 'specialChars']) .. GENERATED FROM PYTHON SOURCE LINES 40-42 Run the Check ============= .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: default ConflictingLabels().run(phishing_dataset) .. raw:: html
Conflicting Labels


.. GENERATED FROM PYTHON SOURCE LINES 46-47 We can also check label ambiguity on a subset of the features: .. GENERATED FROM PYTHON SOURCE LINES 47-50 .. code-block:: default ConflictingLabels(n_to_show=1).run(phishing_dataset) .. raw:: html
Conflicting Labels


.. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: default ConflictingLabels(columns=['urlLength', 'numDigits']).run(phishing_dataset) .. raw:: html
Conflicting Labels


.. GENERATED FROM PYTHON SOURCE LINES 55-60 Define a Condition ================== Now, we define a condition that enforces that the ratio of samples with conflicting labels should be 0. A condition is deepchecks' way to validate model and data quality, and let you know if anything goes wrong. .. GENERATED FROM PYTHON SOURCE LINES 60-65 .. code-block:: default check = ConflictingLabels() check.add_condition_ratio_of_conflicting_labels_less_or_equal(0) result = check.run(phishing_dataset) result.show(show_additional_outputs=False) .. raw:: html
Conflicting Labels


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 7.065 seconds) .. _sphx_glr_download_checks_gallery_tabular_data_integrity_plot_conflicting_labels.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_conflicting_labels.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_conflicting_labels.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_