Credit Card Fraud Detection Project - COMP 379/479 Machine Learning Ololade Akinsanola, Oliver Schramm, Eric Spencer, Tigist Tefera, and Avery Walker# Data Download
[#1] import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split import os from imblearn.over_sampling import SMOTE from collections import Counter import xgboost [#2] # 1. Install Kaggle CLI !pip install kaggle # 2. Write your credentials to ~/.kaggle/kaggle.json import os, json # Ensure the directory exists os.makedirs(os.path.expanduser("~/.kaggle"), exist_ok=True) creds = { "username": "ericspencer00", "key": "xxxxxxxxxxxxxxxxx" } # Write and secure the file with open(os.path.expanduser("~/.kaggle/kaggle.json"), "w") as f: json.dump(creds, f) os.chmod(os.path.expanduser("~/.kaggle/kaggle.json"), 0o600) # 3. Point Kaggle CLI at that folder os.environ["KAGGLE_CONFIG_DIR"] = os.path.expanduser("~/.kaggle") # 4. Download & unzip the dataset !kaggle datasets download -d mlg-ulb/creditcardfraud -p . --unzip # 5. Load into pandas import pandas as pd data = pd.read_csv("creditcard.csv") print("Data downloaded successfully.") print(data.head()) Output:
Jan 0001