Created
December 15, 2023 13:37
-
-
Save santiviquez/36282f6fc6115e33c5c650141345baf3 to your computer and use it in GitHub Desktop.
js_distance_toy_example.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import pandas as pd | |
| import nannyml as nml | |
| import matplotlib.pyplot as plt | |
| reference_df = pd.DataFrame({'feature': np.random.normal(0, 0.1, 3000)}) | |
| analysis_df = pd.DataFrame({'feature': np.random.normal(0, 0.12, 3000)}) | |
| calc = nml.UnivariateDriftCalculator( | |
| column_names=['feature'], | |
| continuous_methods=['jensen_shannon'], | |
| chunk_size=1000 | |
| ) | |
| calc.fit(reference_df) | |
| results = calc.calculate(analysis_df) | |
| results.plot(kind='drift').show() | |
| results.plot(kind='distribution').show() | |
| plt.hist(reference_df.feature, 30, density=True) | |
| plt.hist(analysis_df.feature, 30, density=True) | |
| plt.show() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The example above returns the following results.
JS-distance for analysis chunks close to 0.1
