Repository: deepchecks/deepchecks

Issue:
[DOCS] Improve Dominant Frequency Change Check notebook
Follow the guidelines on #543


Discussion:

Resolving patch:
diff --git a/docs/source/examples/tabular/checks/integrity/source/plot_dominant_frequency_change.py b/docs/source/examples/tabular/checks/integrity/source/plot_dominant_frequency_change.py
--- a/docs/source/examples/tabular/checks/integrity/source/plot_dominant_frequency_change.py
+++ b/docs/source/examples/tabular/checks/integrity/source/plot_dominant_frequency_change.py
@@ -2,43 +2,59 @@
 """
 Dominant Frequency Change
 *************************
-"""
+This example provides an overview for using and understanding the `Dominant Frequency Change` check.
 
-#%%
-# Imports
-# =======
+**Structure:**
 
-import pandas as pd
-from sklearn.datasets import load_iris
-from sklearn.model_selection import train_test_split
-from deepchecks.tabular.checks.integrity import DominantFrequencyChange
-from deepchecks.tabular import Dataset
+* `What is a Dominant Frequency Change? <#what-is-a-dominant-frequency-change>`__
+* `Generate Data <#generate-data>`__
+* `Run The Check <#run-the-check>`__
+* `Define a Condition <#define-a-condition>`__
 
-#%%
-# Generating Data
-# ===============
+What is a Dominant Frequency Change?
+====================================
+Dominant Frequency Change is a data integrity check which simply checks whether dominant values have increased
+significantly between test data and train data. Sharp changes in dominant values can indicate a problem with the
+data collection or data processing pipeline (for example, a sharp incrase in a common null or constant value),
+and will cause the model to fail to generalize well. This check goal is to catch these issues early in the pipeline.
 
-iris = load_iris(return_X_y=False, as_frame=True)
-X = iris.data
-y = iris.target
-X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=55)
-train_dataset = Dataset(pd.concat([X_train, y_train], axis=1), 
-            features=iris.feature_names,
-            label='target')
+This check compares the dominant values of each feature in the test data to the dominant values of the same feature in
+the train data. If the ratio of the test to train dominant values is greater than a threshold, the check fails.
+This threshold can be configured by specifying the `ratio_change_thres` parameter of the check.
 
-test_df = pd.concat([X_test, y_test], axis=1)
+The Definition of a Dominant Value
+----------------------------------
+The dominant value is defined as a value that is frequent in data at least more than ``dominance_ratio`` times from the
+next most frequent value. The ``dominance_ratio`` is a configurable parameter of the check.
 
-# make duplicates in the test data
-test_df.loc[test_df.index % 2 == 0, 'petal length (cm)'] = 5.1
-test_df.loc[test_df.index / 3 > 8, 'sepal width (cm)'] = 2.7
+"""
 
-validation_dataset = Dataset(test_df, 
-            features=iris.feature_names,
-            label='target')
+from deepchecks.tabular.checks.integrity import DominantFrequencyChange
+from deepchecks.tabular.datasets.classification import iris
+#%%
+# Generate data
+# =============
+train_ds, test_ds = iris.load_data(data_format='Dataset', as_train_test=True)
 
 #%%
-# Running ``dominant_frequency_change`` check
-# ===========================================
+# Introducing Duplicates in the Test Data
+# -----------------------------------------
 
+# make duplicates in the test data
+test_ds.data.loc[test_ds.data.index % 2 == 0, 'petal length (cm)'] = 5.1
+test_ds.data.loc[test_ds.data.index / 3 > 8, 'sepal width (cm)'] = 2.7
+
+#%%
+# Run The Check
+# =============
+
+check = DominantFrequencyChange()
+check.run(test_ds, train_ds)
+
+#%%
+# Define a Condition
+# ===================
 check = DominantFrequencyChange()
-check.run(validation_dataset, train_dataset)
+check.add_condition_ratio_of_change_not_greater_than(0.1)
+res = check.run(test_ds, train_ds)
+res.show(show_additional_outputs=False)
diff --git a/docs/source/examples/tabular/checks/performance/source/plot_segement_performance.py b/docs/source/examples/tabular/checks/performance/source/plot_segment_performance.py
similarity index 100%
rename from docs/source/examples/tabular/checks/performance/source/plot_segement_performance.py
rename to docs/source/examples/tabular/checks/performance/source/plot_segment_performance.py


Test patch: