text_html_output_1.png
from sklearn.utils import resample

import pandas as pd

df = pd.read_csv('/kaggle/input/credit-card-fraud-detection/creditcard.csv')

df_train = pd.concat([X_train, y_train], axis='columns')

df_not_fraud = df_train[df_train['Class'] == 0]
df_fraud = df_train[df_train['Class'] == 1]

df_not_fraud_downsample = resample(df_not_fraud, replace=False, n_samples=len(df_fraud), random_state=1234)

df_downsampled = pd.concat([df_not_fraud_downsample, df_fraud])

df_downsampled['Class'].value_counts()