YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

πŸ“‰ American Bankruptcy Prediction - Data Science Project

πŸ“Œ Project Overview

This project applies end-to-end Machine Learning techniques to predict whether an American company will go bankrupt based on financial data. The dataset contains financial attributes (X1-X18) for thousands of companies. The project follows a structured Data Science pipeline:

  1. Exploratory Data Analysis (EDA)
  2. Feature Engineering & Clustering
  3. Regression Task: Predicting Net Income (X1).
  4. Classification Task: Predicting Financial Stability (High/Low) based on median split.

πŸŽ₯ Presentation Video

Watch the full project walkthrough and code explanation here: (https://www.loom.com/share/c0e6ce867ce0412cba909c3406707ff3)


πŸ“Š Part 1: Exploratory Data Analysis (EDA)

We started by analyzing the raw data structure, distributions, and correlations.

1. Correlation Matrix

We analyzed the correlation between different financial features. Strong correlations helped us identify redundant features and potential interactions. Correlation Matrix

2. Initial Target Distribution

The original dataset labels ('alive' vs 'failed') were highly imbalanced. Target Distribution


πŸ› οΈ Part 2: Feature Engineering & Clustering

To improve model performance, we engineered new features:

  1. Interactions: Multiplied strong features (e.g., X16 * X7).
  2. Ratios: Created financial ratios (e.g., X2 / X3).
  3. Clustering: Used K-Means to group companies into 3 clusters and added the Cluster_ID as a new feature for the supervised models.

K-Means Clustering Visualization (PCA)

Clusters


πŸ“ˆ Part 3: Regression Task

Goal: Predict the continuous variable X1 (Net Income) using the engineered features.

Model Comparison

We trained and compared three models: Linear Regression (Ridge), Random Forest Regressor, and Gradient Boosting.

Model RMSE (Lower is better) RΒ² Score (Higher is better)
Ridge Regression πŸ† 0.012 0.9999
Random Forest 888.67 0.934
Gradient Boosting 906.24 0.931

πŸ† Winning Model: Ridge Regression

The Ridge Regression model achieved a near-perfect R2 score, indicating a strong linear relationship in the financial features. Below is the Feature Importance showing the most influential predictors: Feature Importance


🧩 Part 4: Classification Task

Goal: We converted the problem into a classification task by splitting the target X1 by its Median.

  • Class 0: Low Income (Below Median)
  • Class 1: High Income (Above Median)

Class Balance (After Split)

Using the median split ensured a perfectly balanced dataset for training: New Class Balance

Model Comparison

We compared Logistic Regression, XGBoost, and Random Forest.

Model F1-Score Accuracy Recall (Class 1)
Random Forest πŸ† 0.9976 0.9976 0.997
XGBoost 0.9970 0.9970 0.996
Logistic Regression 0.9931 0.9931 0.992

πŸ† Winning Model: Random Forest Classifier

The Random Forest model outperformed others. Confusion Matrix: The model made very few errors on the test set. Confusion Matrix


πŸ“‚ Repository Contents

This repository contains all necessary files to reproduce the results:

  • intro_to_data_science_2.ipynb: The complete Python notebook with code, analysis, and visualizations.
  • american_bankruptcy.csv: The dataset used for training and testing.
  • best_regression_model.pkl: The trained Ridge Regression model.
  • best_classification_model.pkl: The trained Random Forest Classification model.
  • *.png: Visualization images generated during the process.

Submitted as part of the Data Science Course Assignment.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support