.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "checks_gallery/tabular/train_test_validation/plot_train_test_samples_mix.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_checks_gallery_tabular_train_test_validation_plot_train_test_samples_mix.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_checks_gallery_tabular_train_test_validation_plot_train_test_samples_mix.py:


.. _plot_tabular_train_test_samples_mix:

Train Test Samples Mix
**********************
This notebook provides an overview for using and understanding the Train Test Samples Mix check.

**Structure:**

* `Why is samples mix unwanted? <#why-is-samples-mix-unwanted>`__
* `Run the check <#run-the-check>`__
* `Define a condition <#define-a-condition>`__

Why is samples mix unwanted?
=============================
Samples mix is when the train and test datasets have some samples in common.
We use the test dataset in order to evaluate our model performance, and having samples in common with the train dataset
will lead to biased metrics, which does not represent the real performance we will get in a real scenario. Therefore,
we always want to avoid samples mix.

Run the check
=============
We will run the check on the iris dataset.

.. GENERATED FROM PYTHON SOURCE LINES 26-40

.. code-block:: default


    from deepchecks.tabular import Dataset
    from deepchecks.tabular.checks import TrainTestSamplesMix
    from deepchecks.tabular.datasets.classification import iris

    # Create data with leakage from train to test
    train, test = iris.load_data()
    bad_test_df = test.data.append(train.data.iloc[[0, 1, 1, 2, 3, 4, 2, 2, 10]], ignore_index=True)
    bad_test = test.copy(bad_test_df)

    check = TrainTestSamplesMix()
    result = check.run(test_dataset=bad_test, train_dataset=train)
    result






.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <!--
        ~ ----------------------------------------------------------------------------
        ~ Copyright (C) 2021-2023 Deepchecks (https://www.deepchecks.com)
        ~
        ~ This file is part of Deepchecks.
        ~ Deepchecks is distributed under the terms of the GNU Affero General
        ~ Public License (version 3 or later).
        ~ You should have received a copy of the GNU Affero General Public License
        ~ along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
        ~ ----------------------------------------------------------------------------
        ~
    -->
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Train Test Samples Mix</title>
        <link rel="icon" type="image/x-icon" href="https://deepchecks.com/wp-content/themes/deepchecks/assets/favicons/favicon.ico">
        <style>
            body {
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
                font-size: 1rem;
                line-height: 1.5;
                color: #212529;
                text-align: left;
                max-width: 1200px;
                margin: auto;
                background-color: white;
            }

            div.nbinput.container div.prompt *,
            div.nboutput.container div.prompt *,
            div.nbinput.container div.input_area pre,
            div.nboutput.container div.output_area pre,
            div.nbinput.container div.input_area .highlight,
            div.nboutput.container div.output_area .highlight {
                border: none;
                padding: 0;
                margin: 0;
                box-shadow: none;
            }

            div.nbinput.container > div[class*=highlight],
            div.nboutput.container > div[class*=highlight] {
                margin: 0;
            }

            div.nbinput.container div.prompt *,
            div.nboutput.container div.prompt * {
                background: none;
            }

            div.nboutput.container div.output_area .highlight,
            div.nboutput.container div.output_area pre {
                background: unset;
            }

            div.nboutput.container div.output_area div.highlight {
                color: unset;  /* override Pygments text color */
            }

            /* avoid gaps between output lines */
            div.nboutput.container div[class*=highlight] pre {
                line-height: normal;
            }

            /* input/output containers */
            div.nbinput.container,
            div.nboutput.container {
                display: -webkit-flex;
                display: flex;
                align-items: flex-start;
                margin: 0;
                width: 100%;
            }
            @media (max-width: 540px) {
                div.nbinput.container,
                div.nboutput.container {
                    flex-direction: column;
                }
            }

            /* input container */
            div.nbinput.container {
                padding-top: 5px;
            }

            /* last container */
            div.nblast.container {
                padding-bottom: 5px;
            }

            /* input prompt */
            div.nbinput.container div.prompt pre {
                color: #307FC1;
            }

            /* output prompt */
            div.nboutput.container div.prompt pre {
                color: #BF5B3D;
            }

            /* all prompts */
            div.nbinput.container div.prompt,
            div.nboutput.container div.prompt {
                width: 4.5ex;
                padding-top: 5px;
                position: relative;
                user-select: none;
            }

            div.nbinput.container div.prompt > div,
            div.nboutput.container div.prompt > div {
                position: absolute;
                right: 0;
                margin-right: 0.3ex;
            }

            @media (max-width: 540px) {
                div.nbinput.container div.prompt,
                div.nboutput.container div.prompt {
                    width: unset;
                    text-align: left;
                    padding: 0.4em;
                }
                div.nboutput.container div.prompt.empty {
                    padding: 0;
                }

                div.nbinput.container div.prompt > div,
                div.nboutput.container div.prompt > div {
                    position: unset;
                }
            }

            /* disable scrollbars on prompts */
            div.nbinput.container div.prompt pre,
            div.nboutput.container div.prompt pre {
                overflow: hidden;
            }

            /* input/output area */
            div.nbinput.container div.input_area,
            div.nboutput.container div.output_area {
                -webkit-flex: 1;
                flex: 1;
                overflow: auto;
            }
            @media (max-width: 540px) {
                div.nbinput.container div.input_area,
                div.nboutput.container div.output_area {
                    width: 100%;
                }
            }

            /* input area */
            div.nbinput.container div.input_area {
                border: 1px solid #e0e0e0;
                border-radius: 2px;
                /*background: #f5f5f5;*/
            }

            /* override MathJax center alignment in output cells */
            div.nboutput.container div[class*=MathJax] {
                text-align: left !important;
            }

            /* override sphinx.ext.imgmath center alignment in output cells */
            div.nboutput.container div.math p {
                text-align: left;
            }

            /* standard error */
            div.nboutput.container div.output_area.stderr {
                background: #fdd;
            }

            /* ANSI colors */
            .ansi-black-fg { color: #3E424D; }
            .ansi-black-bg { background-color: #3E424D; }
            .ansi-black-intense-fg { color: #282C36; }
            .ansi-black-intense-bg { background-color: #282C36; }
            .ansi-red-fg { color: #E75C58; }
            .ansi-red-bg { background-color: #E75C58; }
            .ansi-red-intense-fg { color: #B22B31; }
            .ansi-red-intense-bg { background-color: #B22B31; }
            .ansi-green-fg { color: #00A250; }
            .ansi-green-bg { background-color: #00A250; }
            .ansi-green-intense-fg { color: #007427; }
            .ansi-green-intense-bg { background-color: #007427; }
            .ansi-yellow-fg { color: #DDB62B; }
            .ansi-yellow-bg { background-color: #DDB62B; }
            .ansi-yellow-intense-fg { color: #B27D12; }
            .ansi-yellow-intense-bg { background-color: #B27D12; }
            .ansi-blue-fg { color: #208FFB; }
            .ansi-blue-bg { background-color: #208FFB; }
            .ansi-blue-intense-fg { color: #0065CA; }
            .ansi-blue-intense-bg { background-color: #0065CA; }
            .ansi-magenta-fg { color: #D160C4; }
            .ansi-magenta-bg { background-color: #D160C4; }
            .ansi-magenta-intense-fg { color: #A03196; }
            .ansi-magenta-intense-bg { background-color: #A03196; }
            .ansi-cyan-fg { color: #60C6C8; }
            .ansi-cyan-bg { background-color: #60C6C8; }
            .ansi-cyan-intense-fg { color: #258F8F; }
            .ansi-cyan-intense-bg { background-color: #258F8F; }
            .ansi-white-fg { color: #C5C1B4; }
            .ansi-white-bg { background-color: #C5C1B4; }
            .ansi-white-intense-fg { color: #A1A6B2; }
            .ansi-white-intense-bg { background-color: #A1A6B2; }

            .ansi-default-inverse-fg { color: #FFFFFF; }
            .ansi-default-inverse-bg { background-color: #000000; }

            .ansi-bold { font-weight: bold; }
            .ansi-underline { text-decoration: underline; }


            div.nbinput.container div.input_area div[class*=highlight] > pre,
            div.nboutput.container div.output_area div[class*=highlight] > pre,
            div.nboutput.container div.output_area div[class*=highlight].math,
            div.nboutput.container div.output_area.rendered_html,
            div.nboutput.container div.output_area > div.output_javascript,
            div.nboutput.container div.output_area:not(.rendered_html) > img{
                padding: 5px;
                margin: 0;
            }

            /* fix copybtn overflow problem in chromium (needed for 'sphinx_copybutton') */
            div.nbinput.container div.input_area > div[class^='highlight'],
            div.nboutput.container div.output_area > div[class^='highlight']{
                overflow-y: hidden;
            }

            /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */
            .prompt .copybtn {
                display: none;
            }

            /* Some additional styling taken form the Jupyter notebook CSS */
            div.rendered_html table {
            border: none;
            border-collapse: collapse;
            border-spacing: 0;
            color: black;
            font-size: 12px;
            table-layout: fixed;
            }
            div.rendered_html thead {
            border-bottom: 1px solid black;
            vertical-align: bottom;
            }
            div.rendered_html tr,
            div.rendered_html th,
            div.rendered_html td {
            text-align: right;
            vertical-align: middle;
            padding: 0.5em 0.5em;
            line-height: normal;
            white-space: normal;
            max-width: none;
            border: none;
            }
            div.rendered_html th {
            font-weight: bold;
            }
            div.rendered_html tbody tr:nth-child(odd) {
            background: #f5f5f5;
            }
            div.rendered_html tbody tr:hover {
            background: rgba(66, 165, 245, 0.2);
            }
        </style>
    </head>
    <body>
        <script src="https://unpkg.com/@jupyter-widgets/html-manager@^0.20.1/dist/embed.js" crossorigin="anonymous"></script>
    

    <script type="application/vnd.jupyter.widget-state+json">
    {"version_major": 2, "version_minor": 0, "state": {"722e485a570f492b9a8b2aeb9a503a4f": {"model_name": "VBoxModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": ["rendered_html", "jp-RenderedHTMLCommon", "jp-RenderedHTML", "jp-OutputArea-output"], "children": ["IPY_MODEL_1b7b17cea35f4d398a3edefd7d13607b", "IPY_MODEL_80ca030d38d74fdd8ac6968ad54731be", "IPY_MODEL_3aa670579a7042678a131dc3a10d5020", "IPY_MODEL_a5444bfc2217497f8fdd8231cc4b9f0d"], "layout": "IPY_MODEL_32bfbcfbb95048d8a9f949274ab7ee0c"}}, "1b7b17cea35f4d398a3edefd7d13607b": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_7ebcbc599ec04414bcbf347f5a1da5df", "style": "IPY_MODEL_614f776098c842b994352cbb415d8b85", "value": "<h4><b>Train Test Samples Mix</b></h4>"}}, "7ebcbc599ec04414bcbf347f5a1da5df": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "614f776098c842b994352cbb415d8b85": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "80ca030d38d74fdd8ac6968ad54731be": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_7c0014f4889945979cc1c09c95a0c6db", "style": "IPY_MODEL_9b6f4507ede747faa4a8ad2508ca4a49", "value": "<p>Detect samples in the test data that appear also in training data. <a href=\"https://docs.deepchecks.com/0.13/checks_gallery/tabular/train_test_validation/plot_train_test_samples_mix.html?utm_source=display_output&utm_medium=referral&utm_campaign=check_link\" target=\"_blank\">Read More...</a></p>"}}, "7c0014f4889945979cc1c09c95a0c6db": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "9b6f4507ede747faa4a8ad2508ca4a49": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "3aa670579a7042678a131dc3a10d5020": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_a1e056afea3e4399853741e681af4beb", "style": "IPY_MODEL_70c6c997d5b84a7f8e7349575cc27cba"}}, "a1e056afea3e4399853741e681af4beb": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "70c6c997d5b84a7f8e7349575cc27cba": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "a5444bfc2217497f8fdd8231cc4b9f0d": {"model_name": "VBoxModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "children": ["IPY_MODEL_f495eac46795488c85e5f42e11992c6c", "IPY_MODEL_896db61331cc416183e0e8610789937e", "IPY_MODEL_67275d5da1d44f4ba60f26eacec3d3c4"], "layout": "IPY_MODEL_3c90428adae4443dbcee53ae237692a4"}}, "f495eac46795488c85e5f42e11992c6c": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_0738c6301401462fb8d7016aebed40da", "style": "IPY_MODEL_ac10b7fa7c9b409e8c30f8ecf4ebbc22", "value": "<h5><b>Additional Outputs</b></h5>"}}, "0738c6301401462fb8d7016aebed40da": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "ac10b7fa7c9b409e8c30f8ecf4ebbc22": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "896db61331cc416183e0e8610789937e": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_a7f17e8a3f624d908eb3a931501fb22d", "style": "IPY_MODEL_68f870f2849646b38e7c223eda236f1a", "value": "<div>21.28% (10 / 47)                      of test data samples appear in train data</div>"}}, "a7f17e8a3f624d908eb3a931501fb22d": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "68f870f2849646b38e7c223eda236f1a": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "67275d5da1d44f4ba60f26eacec3d3c4": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_46fbd2a461ac44fc8ffd1a9e43d961a1", "style": "IPY_MODEL_e1e906cbbc624abbb57e85bfbd691c08", "value": "<style type=\"text/css\">\n#T_8a2a3_ table {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_8a2a3_ thead {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_8a2a3_ tbody {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_8a2a3_ th {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_8a2a3_ td {\n  text-align: left;\n  white-space: pre-wrap;\n}\n</style>\n<table id=\"T_8a2a3_\">\n  <thead>\n    <tr>\n      <th class=\"blank level0\" >&nbsp;</th>\n      <th class=\"col_heading level0 col0\" >sepal length (cm)</th>\n      <th class=\"col_heading level0 col1\" >sepal width (cm)</th>\n      <th class=\"col_heading level0 col2\" >petal length (cm)</th>\n      <th class=\"col_heading level0 col3\" >petal width (cm)</th>\n      <th class=\"col_heading level0 col4\" >target</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th id=\"T_8a2a3_level0_row0\" class=\"row_heading level0 row0\" >Train indices: 2\nTest indices: 44, 45, 41</th>\n      <td id=\"T_8a2a3_row0_col0\" class=\"data row0 col0\" >4.40</td>\n      <td id=\"T_8a2a3_row0_col1\" class=\"data row0 col1\" >2.90</td>\n      <td id=\"T_8a2a3_row0_col2\" class=\"data row0 col2\" >1.40</td>\n      <td id=\"T_8a2a3_row0_col3\" class=\"data row0 col3\" >0.20</td>\n      <td id=\"T_8a2a3_row0_col4\" class=\"data row0 col4\" >0.00</td>\n    </tr>\n    <tr>\n      <th id=\"T_8a2a3_level0_row1\" class=\"row_heading level0 row1\" >Train indices: 1\nTest indices: 39, 40</th>\n      <td id=\"T_8a2a3_row1_col0\" class=\"data row1 col0\" >4.90</td>\n      <td id=\"T_8a2a3_row1_col1\" class=\"data row1 col1\" >3.00</td>\n      <td id=\"T_8a2a3_row1_col2\" class=\"data row1 col2\" >1.40</td>\n      <td id=\"T_8a2a3_row1_col3\" class=\"data row1 col3\" >0.20</td>\n      <td id=\"T_8a2a3_row1_col4\" class=\"data row1 col4\" >0.00</td>\n    </tr>\n    <tr>\n      <th id=\"T_8a2a3_level0_row2\" class=\"row_heading level0 row2\" >Train indices: 4\nTest indices: 43</th>\n      <td id=\"T_8a2a3_row2_col0\" class=\"data row2 col0\" >4.90</td>\n      <td id=\"T_8a2a3_row2_col1\" class=\"data row2 col1\" >2.50</td>\n      <td id=\"T_8a2a3_row2_col2\" class=\"data row2 col2\" >4.50</td>\n      <td id=\"T_8a2a3_row2_col3\" class=\"data row2 col3\" >1.70</td>\n      <td id=\"T_8a2a3_row2_col4\" class=\"data row2 col4\" >2.00</td>\n    </tr>\n    <tr>\n      <th id=\"T_8a2a3_level0_row3\" class=\"row_heading level0 row3\" >Train indices: 0\nTest indices: 38</th>\n      <td id=\"T_8a2a3_row3_col0\" class=\"data row3 col0\" >5.00</td>\n      <td id=\"T_8a2a3_row3_col1\" class=\"data row3 col1\" >2.00</td>\n      <td id=\"T_8a2a3_row3_col2\" class=\"data row3 col2\" >3.50</td>\n      <td id=\"T_8a2a3_row3_col3\" class=\"data row3 col3\" >1.00</td>\n      <td id=\"T_8a2a3_row3_col4\" class=\"data row3 col4\" >1.00</td>\n    </tr>\n    <tr>\n      <th id=\"T_8a2a3_level0_row4\" class=\"row_heading level0 row4\" >Train indices: 3\nTest indices: 42</th>\n      <td id=\"T_8a2a3_row4_col0\" class=\"data row4 col0\" >5.00</td>\n      <td id=\"T_8a2a3_row4_col1\" class=\"data row4 col1\" >2.30</td>\n      <td id=\"T_8a2a3_row4_col2\" class=\"data row4 col2\" >3.30</td>\n      <td id=\"T_8a2a3_row4_col3\" class=\"data row4 col3\" >1.00</td>\n      <td id=\"T_8a2a3_row4_col4\" class=\"data row4 col4\" >1.00</td>\n    </tr>\n    <tr>\n      <th id=\"T_8a2a3_level0_row5\" class=\"row_heading level0 row5\" >Train indices: 30\nTest indices: 28</th>\n      <td id=\"T_8a2a3_row5_col0\" class=\"data row5 col0\" >5.80</td>\n      <td id=\"T_8a2a3_row5_col1\" class=\"data row5 col1\" >2.70</td>\n      <td id=\"T_8a2a3_row5_col2\" class=\"data row5 col2\" >5.10</td>\n      <td id=\"T_8a2a3_row5_col3\" class=\"data row5 col3\" >1.90</td>\n      <td id=\"T_8a2a3_row5_col4\" class=\"data row5 col4\" >2.00</td>\n    </tr>\n    <tr>\n      <th id=\"T_8a2a3_level0_row6\" class=\"row_heading level0 row6\" >Train indices: 10\nTest indices: 46</th>\n      <td id=\"T_8a2a3_row6_col0\" class=\"data row6 col0\" >5.80</td>\n      <td id=\"T_8a2a3_row6_col1\" class=\"data row6 col1\" >4.00</td>\n      <td id=\"T_8a2a3_row6_col2\" class=\"data row6 col2\" >1.20</td>\n      <td id=\"T_8a2a3_row6_col3\" class=\"data row6 col3\" >0.20</td>\n      <td id=\"T_8a2a3_row6_col4\" class=\"data row6 col4\" >0.00</td>\n    </tr>\n  </tbody>\n</table>\n"}}, "46fbd2a461ac44fc8ffd1a9e43d961a1": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "e1e906cbbc624abbb57e85bfbd691c08": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "3c90428adae4443dbcee53ae237692a4": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "32bfbcfbb95048d8a9f949274ab7ee0c": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}}}
    </script>
    <script type="application/vnd.jupyter.widget-view+json">
    {"version_major": 2, "version_minor": 0, "model_id": "722e485a570f492b9a8b2aeb9a503a4f"}
    </script>

    </body>
    </html>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 41-45

Define a condition
==================
We can define a condition that enforces that the ratio of samples in test which appears in train is below a given
amount, the default is `0.1`.

.. GENERATED FROM PYTHON SOURCE LINES 45-48

.. code-block:: default

    check = TrainTestSamplesMix().add_condition_duplicates_ratio_less_or_equal()
    result = check.run(test_dataset=bad_test, train_dataset=train)
    result.show(show_additional_outputs=False)





.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <!--
        ~ ----------------------------------------------------------------------------
        ~ Copyright (C) 2021-2023 Deepchecks (https://www.deepchecks.com)
        ~
        ~ This file is part of Deepchecks.
        ~ Deepchecks is distributed under the terms of the GNU Affero General
        ~ Public License (version 3 or later).
        ~ You should have received a copy of the GNU Affero General Public License
        ~ along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
        ~ ----------------------------------------------------------------------------
        ~
    -->
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Train Test Samples Mix</title>
        <link rel="icon" type="image/x-icon" href="https://deepchecks.com/wp-content/themes/deepchecks/assets/favicons/favicon.ico">
        <style>
            body {
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
                font-size: 1rem;
                line-height: 1.5;
                color: #212529;
                text-align: left;
                max-width: 1200px;
                margin: auto;
                background-color: white;
            }

            div.nbinput.container div.prompt *,
            div.nboutput.container div.prompt *,
            div.nbinput.container div.input_area pre,
            div.nboutput.container div.output_area pre,
            div.nbinput.container div.input_area .highlight,
            div.nboutput.container div.output_area .highlight {
                border: none;
                padding: 0;
                margin: 0;
                box-shadow: none;
            }

            div.nbinput.container > div[class*=highlight],
            div.nboutput.container > div[class*=highlight] {
                margin: 0;
            }

            div.nbinput.container div.prompt *,
            div.nboutput.container div.prompt * {
                background: none;
            }

            div.nboutput.container div.output_area .highlight,
            div.nboutput.container div.output_area pre {
                background: unset;
            }

            div.nboutput.container div.output_area div.highlight {
                color: unset;  /* override Pygments text color */
            }

            /* avoid gaps between output lines */
            div.nboutput.container div[class*=highlight] pre {
                line-height: normal;
            }

            /* input/output containers */
            div.nbinput.container,
            div.nboutput.container {
                display: -webkit-flex;
                display: flex;
                align-items: flex-start;
                margin: 0;
                width: 100%;
            }
            @media (max-width: 540px) {
                div.nbinput.container,
                div.nboutput.container {
                    flex-direction: column;
                }
            }

            /* input container */
            div.nbinput.container {
                padding-top: 5px;
            }

            /* last container */
            div.nblast.container {
                padding-bottom: 5px;
            }

            /* input prompt */
            div.nbinput.container div.prompt pre {
                color: #307FC1;
            }

            /* output prompt */
            div.nboutput.container div.prompt pre {
                color: #BF5B3D;
            }

            /* all prompts */
            div.nbinput.container div.prompt,
            div.nboutput.container div.prompt {
                width: 4.5ex;
                padding-top: 5px;
                position: relative;
                user-select: none;
            }

            div.nbinput.container div.prompt > div,
            div.nboutput.container div.prompt > div {
                position: absolute;
                right: 0;
                margin-right: 0.3ex;
            }

            @media (max-width: 540px) {
                div.nbinput.container div.prompt,
                div.nboutput.container div.prompt {
                    width: unset;
                    text-align: left;
                    padding: 0.4em;
                }
                div.nboutput.container div.prompt.empty {
                    padding: 0;
                }

                div.nbinput.container div.prompt > div,
                div.nboutput.container div.prompt > div {
                    position: unset;
                }
            }

            /* disable scrollbars on prompts */
            div.nbinput.container div.prompt pre,
            div.nboutput.container div.prompt pre {
                overflow: hidden;
            }

            /* input/output area */
            div.nbinput.container div.input_area,
            div.nboutput.container div.output_area {
                -webkit-flex: 1;
                flex: 1;
                overflow: auto;
            }
            @media (max-width: 540px) {
                div.nbinput.container div.input_area,
                div.nboutput.container div.output_area {
                    width: 100%;
                }
            }

            /* input area */
            div.nbinput.container div.input_area {
                border: 1px solid #e0e0e0;
                border-radius: 2px;
                /*background: #f5f5f5;*/
            }

            /* override MathJax center alignment in output cells */
            div.nboutput.container div[class*=MathJax] {
                text-align: left !important;
            }

            /* override sphinx.ext.imgmath center alignment in output cells */
            div.nboutput.container div.math p {
                text-align: left;
            }

            /* standard error */
            div.nboutput.container div.output_area.stderr {
                background: #fdd;
            }

            /* ANSI colors */
            .ansi-black-fg { color: #3E424D; }
            .ansi-black-bg { background-color: #3E424D; }
            .ansi-black-intense-fg { color: #282C36; }
            .ansi-black-intense-bg { background-color: #282C36; }
            .ansi-red-fg { color: #E75C58; }
            .ansi-red-bg { background-color: #E75C58; }
            .ansi-red-intense-fg { color: #B22B31; }
            .ansi-red-intense-bg { background-color: #B22B31; }
            .ansi-green-fg { color: #00A250; }
            .ansi-green-bg { background-color: #00A250; }
            .ansi-green-intense-fg { color: #007427; }
            .ansi-green-intense-bg { background-color: #007427; }
            .ansi-yellow-fg { color: #DDB62B; }
            .ansi-yellow-bg { background-color: #DDB62B; }
            .ansi-yellow-intense-fg { color: #B27D12; }
            .ansi-yellow-intense-bg { background-color: #B27D12; }
            .ansi-blue-fg { color: #208FFB; }
            .ansi-blue-bg { background-color: #208FFB; }
            .ansi-blue-intense-fg { color: #0065CA; }
            .ansi-blue-intense-bg { background-color: #0065CA; }
            .ansi-magenta-fg { color: #D160C4; }
            .ansi-magenta-bg { background-color: #D160C4; }
            .ansi-magenta-intense-fg { color: #A03196; }
            .ansi-magenta-intense-bg { background-color: #A03196; }
            .ansi-cyan-fg { color: #60C6C8; }
            .ansi-cyan-bg { background-color: #60C6C8; }
            .ansi-cyan-intense-fg { color: #258F8F; }
            .ansi-cyan-intense-bg { background-color: #258F8F; }
            .ansi-white-fg { color: #C5C1B4; }
            .ansi-white-bg { background-color: #C5C1B4; }
            .ansi-white-intense-fg { color: #A1A6B2; }
            .ansi-white-intense-bg { background-color: #A1A6B2; }

            .ansi-default-inverse-fg { color: #FFFFFF; }
            .ansi-default-inverse-bg { background-color: #000000; }

            .ansi-bold { font-weight: bold; }
            .ansi-underline { text-decoration: underline; }


            div.nbinput.container div.input_area div[class*=highlight] > pre,
            div.nboutput.container div.output_area div[class*=highlight] > pre,
            div.nboutput.container div.output_area div[class*=highlight].math,
            div.nboutput.container div.output_area.rendered_html,
            div.nboutput.container div.output_area > div.output_javascript,
            div.nboutput.container div.output_area:not(.rendered_html) > img{
                padding: 5px;
                margin: 0;
            }

            /* fix copybtn overflow problem in chromium (needed for 'sphinx_copybutton') */
            div.nbinput.container div.input_area > div[class^='highlight'],
            div.nboutput.container div.output_area > div[class^='highlight']{
                overflow-y: hidden;
            }

            /* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */
            .prompt .copybtn {
                display: none;
            }

            /* Some additional styling taken form the Jupyter notebook CSS */
            div.rendered_html table {
            border: none;
            border-collapse: collapse;
            border-spacing: 0;
            color: black;
            font-size: 12px;
            table-layout: fixed;
            }
            div.rendered_html thead {
            border-bottom: 1px solid black;
            vertical-align: bottom;
            }
            div.rendered_html tr,
            div.rendered_html th,
            div.rendered_html td {
            text-align: right;
            vertical-align: middle;
            padding: 0.5em 0.5em;
            line-height: normal;
            white-space: normal;
            max-width: none;
            border: none;
            }
            div.rendered_html th {
            font-weight: bold;
            }
            div.rendered_html tbody tr:nth-child(odd) {
            background: #f5f5f5;
            }
            div.rendered_html tbody tr:hover {
            background: rgba(66, 165, 245, 0.2);
            }
        </style>
    </head>
    <body>
        <script src="https://unpkg.com/@jupyter-widgets/html-manager@^0.20.1/dist/embed.js" crossorigin="anonymous"></script>
    

    <script type="application/vnd.jupyter.widget-state+json">
    {"version_major": 2, "version_minor": 0, "state": {"074e2f1e549e4ba0a878365ae40aac3b": {"model_name": "VBoxModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": ["rendered_html", "jp-RenderedHTMLCommon", "jp-RenderedHTML", "jp-OutputArea-output"], "children": ["IPY_MODEL_5e4aaf85a4b7417db4f7e29aeb1ec3db", "IPY_MODEL_0dc7b98aaf804f75881a50dc07d6783b", "IPY_MODEL_7e473cebac9f42aaa99b9170bcde7bc1"], "layout": "IPY_MODEL_92236361e15c4902924c43cc05edd2a7"}}, "5e4aaf85a4b7417db4f7e29aeb1ec3db": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_a16a589c298f4b8c9b978b9f579032b8", "style": "IPY_MODEL_d36f93a72e54438cbccd2cd338a8dd2a", "value": "<h4><b>Train Test Samples Mix</b></h4>"}}, "a16a589c298f4b8c9b978b9f579032b8": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "d36f93a72e54438cbccd2cd338a8dd2a": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "0dc7b98aaf804f75881a50dc07d6783b": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_c7b256c96a4b44899a5a7ca1952babfe", "style": "IPY_MODEL_7e9ed2f106d146bbb2db8182c7d8d457", "value": "<p>Detect samples in the test data that appear also in training data. <a href=\"https://docs.deepchecks.com/0.13/checks_gallery/tabular/train_test_validation/plot_train_test_samples_mix.html?utm_source=display_output&utm_medium=referral&utm_campaign=check_link\" target=\"_blank\">Read More...</a></p>"}}, "c7b256c96a4b44899a5a7ca1952babfe": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "7e9ed2f106d146bbb2db8182c7d8d457": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "7e473cebac9f42aaa99b9170bcde7bc1": {"model_name": "HTMLModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {"_dom_classes": [], "layout": "IPY_MODEL_3fec2e996a7f41228de2053add24f083", "style": "IPY_MODEL_524accd8baf740279f47309a61f491d5", "value": "<h5><b>Conditions Summary</b></h5><style type=\"text/css\">\n#T_50f08_ table {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_50f08_ thead {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_50f08_ tbody {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_50f08_ th {\n  text-align: left;\n  white-space: pre-wrap;\n}\n#T_50f08_ td {\n  text-align: left;\n  white-space: pre-wrap;\n}\n</style>\n<table id=\"T_50f08_\">\n  <thead>\n    <tr>\n      <th class=\"col_heading level0 col0\" >Status</th>\n      <th class=\"col_heading level0 col1\" >Condition</th>\n      <th class=\"col_heading level0 col2\" >More Info</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td id=\"T_50f08_row0_col0\" class=\"data row0 col0\" ><div style=\"color: red;text-align: center\">\u2716</div></td>\n      <td id=\"T_50f08_row0_col1\" class=\"data row0 col1\" >Percentage of test data samples that appear in train data is less or equal to 10%</td>\n      <td id=\"T_50f08_row0_col2\" class=\"data row0 col2\" >Percent of test data samples that appear in train data: 21.28%</td>\n    </tr>\n  </tbody>\n</table>\n"}}, "3fec2e996a7f41228de2053add24f083": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}, "524accd8baf740279f47309a61f491d5": {"model_name": "DescriptionStyleModel", "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "state": {}}, "92236361e15c4902924c43cc05edd2a7": {"model_name": "LayoutModel", "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "state": {}}}}
    </script>
    <script type="application/vnd.jupyter.widget-view+json">
    {"version_major": 2, "version_minor": 0, "model_id": "074e2f1e549e4ba0a878365ae40aac3b"}
    </script>

    </body>
    </html>
    </div>
    <br />
    <br />


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  1.348 seconds)


.. _sphx_glr_download_checks_gallery_tabular_train_test_validation_plot_train_test_samples_mix.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_train_test_samples_mix.py <plot_train_test_samples_mix.py>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_train_test_samples_mix.ipynb <plot_train_test_samples_mix.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_