text_plain_output_1.png
from sklearn.metrics import f1_score

from xgboost import XGBRegressor

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data = pd.read_csv('/kaggle/input/creditcardfraud/creditcard.csv')

data.isnull().sum()

data.dtypes

X = data.drop('Class', axis=1)
y = data['Class']

from xgboost import XGBRegressor
xgb = XGBRegressor()
xgb.fit(X_train, y_train)
xgb_pred = xgb.predict(X_test)

def xgb_f1(y, t, threshold=0.5):
    y_bin = (y > threshold).astype(int)
    return ('f1', f1_score(t, y_bin))

xgb_f1(xgb_pred, y_test)