{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"# **Assignment #1: EDA & Dataset**\n",
"\n",
"**DATE: March2026**\n",
"\n"
],
"metadata": {
"id": "w84cR3AZIU0e"
}
},
{
"cell_type": "markdown",
"source": [
"### **Overview**\n",
"\n",
"In this first assignment, you will gain hands-on experience selecting and preparing a dataset, performing exploratory data analysis (EDA), adding it to HF's Datasets, and presenting your findings in a short video.\n",
"\n",
"Through these steps, you’ll begin building essential data science skills in Python.\n",
"\n",
"Think of your notebook as a cohesive story where EDA reveals the narrative of your data, which provides the resolution to the main question or goal."
],
"metadata": {
"id": "n7afdXdxIbLA"
}
},
{
"cell_type": "markdown",
"source": [
"### **Objectives**\n",
"\n",
"1. Explore various data tools/hubs (e.g., Kaggle, UCI, or local data) to find a suitable dataset.\n",
"2. Prepare the selected dataset, focusing on cleaning, transformation, manipulation, and quality.\n",
"3. Build foundational EDA skills, including missing data, outlier handling, and clear data visualization.\n",
"4. Upload your work and your dataset to HuggingFace.\n",
"5. Communicate findings concisely in both a structured notebook, README file, and a short video presentation, demonstrating clarity in each step of the workflow."
],
"metadata": {
"id": "lJAPMumvIUyW"
}
},
{
"cell_type": "markdown",
"source": [
"### **Submission Guidelines**\n",
"\n",
"1. Please note that this is an individual assignment.\n",
"2. Submit a text file with your info and the link to HF's dataset.\n",
"3. The dataset will include all of your work.\n",
" - **Python Notebook**: a well-structured notebook (e.g.`.ipynb` file) with clear comments or markdown explanations of each step.\n",
" - **Video Link**: the README file will include your short video presentation at the beginning of the file.\n",
"4. **Oral Report**: Students may be randomly chosen to present their work in a quick online session with the T.A., typically lasting ±10 minutes.\n",
"\n",
"\n",
"\n"
],
"metadata": {
"id": "MwRmaJBiIjMR"
}
},
{
"cell_type": "markdown",
"source": [
"### **Evaluation Criteria**\n",
"\n",
"1. **Organization & Clarity (20%)**: Overall structure of your HF Dataset, code, notebook, clear communication, and a concise summary.\n",
"\n",
"2. **Data Handling (30%)**: Quality of data cleaning, appropriate handling of outliers, and more.\n",
"\n",
"3. **Visualizations (30%)**: well-presented relevant visuals, variety of plot types.\n",
"\n",
"4. **Presentation (20%)**: Clearly communicated approach and findings in your 2–3 minute overview.\n"
],
"metadata": {
"id": "hD9SZmagIjOV"
}
},
{
"cell_type": "markdown",
"source": [
"### **Additional Tips**\n",
"\n",
"- The first thing you should do is download a copy of this notebook to your drive.\n",
"- Keep your dataset size manageable. If the dataset is large, you can sample a subset.\n",
"- A few clear visuals are more effective than many complicated ones.\n",
"- Ask for help or feedback early if you get stuck."
],
"metadata": {
"id": "h3vpVHSxIUwI"
}
},
{
"cell_type": "markdown",
"source": [
"
\n",
"\n",
"---\n",
"\n",
"Reminder: Always start with copy the NOTEBOOK to your drive."
],
"metadata": {
"id": "6kUonEv8Ipkp"
}
},
{
"cell_type": "markdown",
"source": [
""
],
"metadata": {
"id": "RMcHZdKiaPNW"
}
},
{
"cell_type": "markdown",
"source": [
"---\n",
"\n",
"
"
],
"metadata": {
"id": "7ql9QlVfaSEL"
}
},
{
"cell_type": "markdown",
"source": [
"# **Part 1: Select a Dataset**\n",
"\n",
"1. Choose a numeric tabular dataset, such as the . If you prefer, you may use other open-source datasets; [Hugginface](https://huggingface.co/datasets?task_categories=task_categories:tabular-classification&sort=trending), [Kaggle](https://www.kaggle.com/datasets?tags=13302-Classification&minUsabilityRating=8.00+or+higher), etc.\n",
"\n",
"\n",
" Examples for a good dataset:\n",
" - \"Determine a genre of a song\"\n",
" - \"Determine the type of flowers\"\n",
" - \"Determine the animal - cat or dog\"\n",
" - \"Determine the category of a product\"\n",
" - \"Determine if an email is spam or not spam\"\n",
" - \"Determine whether a tumor is malignant or benign\"\n",
" - \"Determine whether a transaction is fraudulent or not\"\n",
" - \"Determine whether a student is likely to pass a course\"\n",
"\n",
"2. Avoid choosing a \"basic\"/\"small\" dataset.\n",
" - 1K rows and more.\n",
" - 10 features and more.\n",
"\n",
"\n",
"3. Please submit your dataset [here](https://forms.gle/YYiRLXJnbwUfwuwc7), to share it with the class so everyone can see.\n",
"And make sure your chosen dataset is unique using this [link](https://docs.google.com/spreadsheets/d/1M8uojrzhSyVnOlSAJpzCKxrhWdzPR77k4x8Kxvr8VDk/edit?usp=sharing).\n",
"\n",
" *Note: Due to their popularity, the following are datasets you may not choose.*\n",
" > - Iris dataset\n",
" > - Wine dataset\n",
" > - Titanic dataset\n",
" > - Boston Housing dataset\n",
" > - ImageNet, Cifar, CelebFaces, IMDB\n",
"\n",
"> (If you happen to change the dataset - submit the new dataset. We're looking on the most current one)\n",
"\n",
"\n",
"4. Choose a dataset with moslty numaric values. This way you would have enough information to work on, and you could drop columns that aren't numeric.\n",
"\n",
"5. Briefly describe your chosen dataset (source, size, features) and the question you want to answer.\n",
"\n",
"6. Clearly identify the target variable to predict (if exists).\n",
"\n",
"\n",
"\n",
"\n"
],
"metadata": {
"id": "a_vsO0Q1IOMT"
}
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"id": "GFaHgQJyKwa5"
}
},
{
"cell_type": "code",
"source": [
"# Dataset chosen: Financial Fraud Detection (PaySim Simulation)\n",
"# Source: This is a real-world inspired simulation sourced from Kaggle, based on a month of financial logs\n",
"# from a mobile money service, designed to simulate fraudulent behavior within legitimate transactions.\n",
"# Size: The original dataset contains 6,362,620 rows and 10 features. For the scope of this assignment\n",
"# I will work with a representative sample to ensure a manageable yet significant EDA process.\n",
"# Features: The dataset maintains a combination of numerical variables and categorical variables.\n",
"# Research Question: How do specific economic indicators, such as transaction types and sudden\n",
"# inconsistencies between account balances, act as financial fingerprints to accurately predict\n",
"# fraudulent activity, and can identifying these logical gaps in the data lead to more efficient\n",
"# and cost-effective detection systems?"
],
"metadata": {
"id": "OI0MZzohKwfE"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"I went with the PaySim dataset because it gave me something that actually feels like real financial data — messy, imbalanced, and full of logical contradictions. As someone studying economics, the research question basically wrote itself once I looked at the columns: when a large transfer happens and the account balance does not shift the way it should, something is clearly wrong. The goal of this analysis is to find out whether those inconsistencies are consistent enough to reliably predict fraud."
],
"metadata": {
"id": "Lgum4x_tKwjL"
}
},
{
"cell_type": "code",
"source": [
"# Target variable identification: isFraud\n",
"# Data type: int64\n",
"# Values: 0 = legitimate transaction, 1 = fraudulent transaction"
],
"metadata": {
"id": "SWIrnfSLKwnE"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"
\n",
"\n",
"---\n",
"\n",
"
"
],
"metadata": {
"id": "4t2QNyE6IPKS"
}
},
{
"cell_type": "markdown",
"source": [
"# **Part 2: Exploratory Data Analysis (EDA)**\n",
"\n",
"Use your EDA to tell the story of your data - highlight interesting patterns, anomalies, or relationships that lead you toward your classification goal. Ask interesting questions, and answer them.\n",
"\n",
"\n",
"1. **Data Cleaning** : Check for missing values, duplicate entries, scaling/normalize issues, parsing dates, fixing typos, or any inconsistencies. Document how you address them.\n",
"2. **Outlier Detection & Handling**: Identify outliers and decide whether to keep or remove them, providing a short justification.\n",
"3. **Descriptive Statistics**: Summarize the data (e.g., mean, median, correlations) to reveal patterns.\n",
"4. Read further on [A Comprehensive Guide to Mastering Exploratory Data Analysis](https://www.dasca.org/world-of-data-science/article/a-comprehensive-guide-to-mastering-exploratory-data-analysis).\n",
"5. **Visualizations**: Use a set of plots (e.g., histograms, scatter plots, box plots) to illustrate **key insights.** Label charts, axes, and legends clearly.\n",
"\n",
"Tip: not necessarily in this order."
],
"metadata": {
"id": "6eLmNWJJIPS0"
}
},
{
"cell_type": "markdown",
"source": [
""
],
"metadata": {
"id": "e3JpM_9Wl84T"
}
},
{
"cell_type": "code",
"source": [
"import pandas as pd # libraries for data manipulation and tables\n",
"import os\n",
"import numpy as np #\n",
"\n",
"import matplotlib.pyplot as plt # libraries for data visualization\n",
"import seaborn as sns\n",
"\n",
"%matplotlib inline\n"
],
"metadata": {
"id": "NuY60Al57ZRQ"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"import kagglehub\n",
"\n",
"# Download latest version\n",
"path = kagglehub.dataset_download(\"chitwanmanchanda/fraudulent-transactions-data\")\n",
"\n",
"print(\"Path to dataset files:\", path)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "bzUjUE937ZUA",
"outputId": "8853eaf5-662a-4a1b-b234-30641e31d1b3"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Downloading to /root/.cache/kagglehub/datasets/chitwanmanchanda/fraudulent-transactions-data/1.archive...\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"100%|██████████| 178M/178M [00:02<00:00, 76.2MB/s]"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"Extracting files...\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"Path to dataset files: /root/.cache/kagglehub/datasets/chitwanmanchanda/fraudulent-transactions-data/versions/1\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"import os\n",
"csv_file = os.listdir(path)[0]\n",
"full_path = os.path.join(path, csv_file)\n",
"df = pd.read_csv(full_path).sample(n=100000, random_state=42) # load the data and take a random sample\n",
"df = df.reset_index(drop=True) # reset index after sampling to keep row numbers clean\n",
"df.head() # display the first few rows to verify"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"id": "CsOcdGzZ7ZW4",
"outputId": "e32a08fe-5fb2-4e79-d716-98d97186a70e"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" step type amount nameOrig oldbalanceOrg newbalanceOrig \\\n",
"0 278 CASH_IN 330218.42 C632336343 20866.00 351084.42 \n",
"1 15 PAYMENT 11647.08 C1264712553 30370.00 18722.92 \n",
"2 10 CASH_IN 152264.21 C1746846248 106589.00 258853.21 \n",
"3 403 TRANSFER 1551760.63 C333676753 0.00 0.00 \n",
"4 206 CASH_IN 78172.30 C813403091 2921331.58 2999503.88 \n",
"\n",
" nameDest oldbalanceDest newbalanceDest isFraud isFlaggedFraud \n",
"0 C834976624 452419.57 122201.15 0 0 \n",
"1 M215391829 0.00 0.00 0 0 \n",
"2 C1607284477 201303.01 49038.80 0 0 \n",
"3 C1564353608 3198359.45 4750120.08 0 0 \n",
"4 C1091768874 415821.90 337649.60 0 0 "
],
"text/html": [
"\n",
"
| \n", " | step | \n", "type | \n", "amount | \n", "nameOrig | \n", "oldbalanceOrg | \n", "newbalanceOrig | \n", "nameDest | \n", "oldbalanceDest | \n", "newbalanceDest | \n", "isFraud | \n", "isFlaggedFraud | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "278 | \n", "CASH_IN | \n", "330218.42 | \n", "C632336343 | \n", "20866.00 | \n", "351084.42 | \n", "C834976624 | \n", "452419.57 | \n", "122201.15 | \n", "0 | \n", "0 | \n", "
| 1 | \n", "15 | \n", "PAYMENT | \n", "11647.08 | \n", "C1264712553 | \n", "30370.00 | \n", "18722.92 | \n", "M215391829 | \n", "0.00 | \n", "0.00 | \n", "0 | \n", "0 | \n", "
| 2 | \n", "10 | \n", "CASH_IN | \n", "152264.21 | \n", "C1746846248 | \n", "106589.00 | \n", "258853.21 | \n", "C1607284477 | \n", "201303.01 | \n", "49038.80 | \n", "0 | \n", "0 | \n", "
| 3 | \n", "403 | \n", "TRANSFER | \n", "1551760.63 | \n", "C333676753 | \n", "0.00 | \n", "0.00 | \n", "C1564353608 | \n", "3198359.45 | \n", "4750120.08 | \n", "0 | \n", "0 | \n", "
| 4 | \n", "206 | \n", "CASH_IN | \n", "78172.30 | \n", "C813403091 | \n", "2921331.58 | \n", "2999503.88 | \n", "C1091768874 | \n", "415821.90 | \n", "337649.60 | \n", "0 | \n", "0 | \n", "