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
| # for reproducibility | |
| np.random.seed(42) | |
| # generate the DataFrame with dates | |
| range_of_dates = pd.date_range( | |
| start="2017-01-01", | |
| end="2020-12-30" | |
| ) | |
| X = pd.DataFrame(index=range_of_dates) | |
| # create a sequence of day numbers | |
| X["day_nr"] = range(len(X)) |
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 matplotlib.pyplot as plt | |
| import seaborn as sns | |
| from datetime import date | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.preprocessing import FunctionTransformer | |
| from sklearn.metrics import mean_absolute_error | |
| from sklego.preprocessing import RepeatingBasisFunction |
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 pandas as pd | |
| import glob | |
| import os | |
| from config import RAW_DIR, PROCESSED_DIR, REPORTS_DIR, AUGMENTED_DIR | |
| from deepchecks.tabular import Dataset | |
| from deepchecks.tabular.suites import full_suite | |
| # prepare output dir for the data validation reports |
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 os | |
| import pandas as pd | |
| from config import RAW_DIR, PROCESSED_DIR, AUGMENTED_DIR | |
| from imblearn.over_sampling import RandomOverSampler, SMOTE, ADASYN | |
| from imblearn.under_sampling import RandomUnderSampler | |
| RANDOM_STATE = 42 | |
| # define the considered augmentations |
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 pandas as pd | |
| from config import RAW_DIR, PROCESSED_DIR | |
| import os | |
| from sklearn.preprocessing import RobustScaler | |
| from sklearn.model_selection import train_test_split | |
| # load data | |
| df = pd.read_csv(f"{RAW_DIR}/creditcard.csv") |
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
| # directories | |
| RAW_DIR = "data/raw" | |
| PROCESSED_DIR = "data/processed" | |
| AUGMENTED_DIR = "data/augmented" | |
| REPORTS_DIR = "data_validation" |
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
| pred_df["TP"] = np.where(pred_df["class"] == 1, pred_df["prob"], 0) | |
| pred_df["FP"] = np.where(pred_df["class"] == 1, 1 - pred_df["prob"], 0) | |
| pred_df["TN"] = np.where(pred_df["class"] == 0, 1- pred_df["prob"], 0) | |
| pred_df["FN"] = np.where(pred_df["class"] == 0, pred_df["prob"], 0) | |
| pred_df |
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 pandas as pd | |
| import numpy as np | |
| pred_df = pd.DataFrame( | |
| data={"class": [1, 1, 1, 0, 0], | |
| "prob": [0.9, 0.85, 0.6, 0.4, 0.2]} | |
| ) | |
| pred_df |
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
| <html> | |
| <head> | |
| <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> | |
| <script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
| <py-env> | |
| - numpy | |
| - matplotlib | |
| </py-env> | |
| </head> |
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
| <html> | |
| <head> | |
| <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> | |
| <script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
| </head> | |
| <body> <py-script> print('Hello, World!') </py-script> </body> | |
| </html> |