This project implements three-way decision (3WD) analysis on binary classification datasets using machine learning models. The three-way decision approach allows models to make three types of decisions:
- Accept (classify as positive with high confidence)
- Reject (classify as negative with high confidence)
- Defer (abstain from making a decision when uncertain)
- Three-Way Decision Analysis
- Datasets Used
- Key Features
- Installation
- Usage
- Project Structure
- License
- Contact
Two publicly available datasets are used for analysis to test different scenarios of class imbalance and feature types.
- Source: UCI Machine Learning Repository (ID: 222)
- Size: 45,211 samples
- Features: 16 original features (38 after one-hot encoding)
- Target: Binary classification (client subscription to term deposit)
- Imbalance: Highly imbalanced (~88% negative, ~12% positive)
- Source: UCI Machine Learning Repository (Adult)
- Size: 32,561 original samples → 14,000 balanced samples
- Features: 14 original features (99 after one-hot encoding)
- Target: Binary classification (income >50K vs ≤50K)
- Balancing: Automatically creates a balanced subset with 7,000 samples per class
- Alpha (α): List of thresholds for accepting positive classification (default:
[0.70, 0.80, 0.90]) - Beta (β): List of thresholds for accepting negative classification (default:
[0.30, 0.20, 0.10]) - Deferral Zone: For each (α, β) pair, predictions with probability between β and α are deferred (i.e.,
β < probability < α)
- Random Forest: 200 estimators, optimized for performance
- Multi-Layer Perceptron (MLP): Neural network with hidden layers (128, 64)
- Binary Classification Results: Standard accuracy, confusion matrices, classification reports
- Three-Way Decision Results: Coverage, accuracy on certain cases, deferral rates
- ROC Curves: With operating points for different α values
- Precision-Recall Curves: For both positive and negative classes
- Calibration Analysis: Probability calibration with Brier scores
- Coverage-Accuracy Trade-off: Systematic sweep of α and β parameters
- Probability Histograms: Distribution of predicted probabilities with decision thresholds
-
Clone the repository
git clone https://github.com/yourusername/three-way-decision-analysis.git cd three-way-decision-analysis -
(Recommended) Create a virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install required dependencies
pip install -r requirements.txt
If
requirements.txtis not present, install the main dependencies manually:pip install scikit-learn numpy pandas matplotlib ucimlrepo
Run the main analysis script
python main.pyThis will:
- Download and preprocess the datasets
- Train Random Forest and MLP models
- Perform three-way decision analysis
- Generate all plots and CSV reports in the
outputs/directory - All output files (plots, confusion matrices, calibration diagrams, etc.) will be saved under
outputs/in subfolders for each dataset.
three-way-decision-analysis/
├── utils/
│ └── functions.py # Helper functions
├── .gitignore # Git ignore file
├── LICENSE # MIT License file
├── main.py # Main script to start the execution of the analysis
├── presentation.pdf # Presentation of the project (in Italian)
├── README.md # This file
├── report.pdf # Description and analysis of obtained results (in Italian)
└── requirements.txt # Python requirements for the project
This project is open source and available under the MIT License.
Ruben Tenderini — GitHub: Ruben-2828 — Email: rubentenderini@gmail.com