This project implements a complete Takagi–Sugeno–Kang (TSK) fuzzy inference system using the Wang–Mendel rule generation method to model mechanical properties of asphalt mixtures.
The system is implemented from scratch using:
-
NumPy
-
Pandas
-
Matplotlib
No external fuzzy logic libraries were used.
-
Model nonlinear relationships between asphalt mixture parameters and mechanical properties.
-
Compare system performance using different numbers of fuzzy partitions.
-
Analyze rule growth and complexity.
-
Evaluate prediction quality using RMSE.
-
Visualize model interpretability and error behavior.
ctx3 print <- this tool is mine! check it's repo!
┌── 📂 Project structure:
├── .gitignore (4699 bytes)
├── README.md (5386 bytes)
├── data (96 bytes)
│ └── Asphalt-Dataset-ToClass.xlsx (32029 bytes)
├── plots (672 bytes) (Generated plots reside here!)
|
├── report (64 bytes)
└── src (352 bytes)
├── data_loader.py (947 bytes)
├── evaluation.py (257 bytes)
├── fuzzy_sets.py (1029 bytes)
├── preprocessing.py (692 bytes)
├── training.py (900 bytes)
├── tsk_model.py (1535 bytes)
├── visualize.py (3399 bytes)
└── wang_mendel.py (1599 bytes)
├── main.py (1886 bytes)
You can use ctx3 (context tree) to quickly grasp the structure. click here to install ctx3
The system follows the classical fuzzy modeling framework:
-
80% training / 20% testing split
-
Random shuffling with fixed seed
-
Min–Max normalization (training statistics only)
Each input variable is partitioned into:
-
2 fuzzy sets
-
3 fuzzy sets
-
4 fuzzy sets
Uniform triangular membership functions are used.
For each training sample:
-
Select maximum membership per input
-
Construct fuzzy rule
-
Assign rule weight
-
Remove duplicates (keep strongest)
Zero-order TSK model:
Where:
-
(
$w_k$ ) = firing strength -
(
$c_k$ ) = rule consequent
Metric used:
After running the project, the following plots are saved inside /plots:
For each of the 4 outputs:
-
RMSE vs number of fuzzy sets
-
Rule count vs number of fuzzy sets
-
True vs predicted scatter
-
Residual distribution
Additionally:
- Membership function visualizations (selected inputs)
Total: ~19 plots.
If you use uv:
uv add numpy pandas matplotlib openpyxl
(If already installed, skip this step.)
uv run main.py
All plots will be saved automatically inside:
./plots
python -m venv venv
Activate it:
Mac/Linux
source venv/bin/activate
Windows
venv\Scripts\activate
pip install numpy pandas matplotlib openpyxl
python main.py
-
Python 3.9+
-
numpy
-
pandas
-
matplotlib
-
openpyxl
Rule count increases with partition granularity.
Best performance was achieved using:
2 fuzzy sets per input
Increasing the number of partitions:
-
Increased rule count
-
Increased model complexity
-
Led to mild overfitting
This demonstrates the classical bias–variance tradeoff.
-
ITSM outputs were predicted more accurately than Flow.
-
Increasing fuzzy granularity without increasing dataset size leads to sparse rule regions.
-
Proper data splitting and normalization were critical to avoid data leakage.
-
Results align with theoretical expectations from fuzzy system theory.
This project successfully demonstrates:
-
End-to-end fuzzy modeling
-
Wang–Mendel rule extraction
-
TSK inference
-
Complexity vs performance tradeoff
-
Interpretability through rule and membership visualization
The implementation is mathematically consistent and academically defensible.
Academic project implementation.