Download eda.py from d-e-e-k-11/Card: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/d-e-e-k-11/Card/resolve/main/eda.py
- Command line
-
hf download hf://d-e-e-k-11/Card/eda.py
-
curl -L -o eda.py https://huggingface.co/d-e-e-k-11/Card/resolve/main/eda.py
1.18 kB
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| # Load dataset | |
| df = pd.read_csv('c:/card/creditcard.csv') | |
| # Basic info | |
| print("Dataset Shape:", df.shape) | |
| print("\nFirst 5 rows:") | |
| print(df.head()) | |
| # Check for missing values | |
| print("\nMissing values:") | |
| print(df.isnull().sum().max()) | |
| # Class distribution | |
| print("\nClass Distribution (0: Normal, 1: Fraud):") | |
| print(df['Class'].value_counts()) | |
| print("\nPercentage:") | |
| print(df['Class'].value_counts(normalize=True) * 100) | |
| # Statistics | |
| print("\nSummary Statistics:") | |
| print(df.describe()) | |
| # Plotting class distribution | |
| plt.figure(figsize=(8, 6)) | |
| sns.countplot(x='Class', data=df, palette='viridis') | |
| plt.title('Class Distribution (0: Normal, 1: Fraud)') | |
| plt.savefig('c:/card/class_distribution.png') | |
| # Plotting distributions of Time and Amount | |
| plt.figure(figsize=(12, 4)) | |
| plt.subplot(1, 2, 1) | |
| sns.histplot(df['Amount'], bins=50, kde=True, color='blue') | |
| plt.title('Transaction Amount Distribution') | |
| plt.subplot(1, 2, 2) | |
| sns.histplot(df['Time'], bins=50, kde=True, color='red') | |
| plt.title('Transaction Time Distribution') | |
| plt.savefig('c:/card/distributions.png') | |