A sophisticated fuzzy logic controller implementation for automated loan approval decisions, combining multiple financial indicators to provide nuanced risk assessment and interest rate recommendations.
- Overview
- Features
- System Architecture
- Installation
- Usage
- Input Variables
- Output Variables
- Fuzzy Rules
- Examples
- Project Structure
- Technical Details
- Future Enhancements
- Contributing
- License
- Acknowledgments
This project implements a Fuzzy Logic Controller (FLC) for loan approval decisions, developed as part of the Computational Intelligence (SAIA 1193) course at Universiti Teknologi Malaysia. Unlike traditional binary decision systems, this fuzzy logic approach handles uncertainty and provides human-like reasoning for complex financial evaluations.
- Handles Uncertainty: Loan decisions involve imprecise information and multiple gray areas
- Human-like Reasoning: Mimics how loan officers evaluate applications using linguistic terms
- Smooth Transitions: Provides gradual transitions between approval categories
- Multi-criteria Analysis: Effectively manages multiple conflicting criteria
- 4 Input Variables: Credit Score, Debt-to-Income Ratio, Annual Income, Employment Duration
- 2 Output Variables: Approval Score (0-100) and Recommended Interest Rate (3-25%)
- 8 Expert-Derived Rules: Based on banking industry best practices
- Comprehensive Visualizations:
- All membership functions
- Complete inference process
- Rule activation strengths
- Defuzzification results
- Three Decision Categories: Approve, Review, Reject
- Risk-Based Pricing: Interest rates automatically adjusted based on risk profile
The system follows a standard four-component fuzzy logic architecture:
Input Variables โ Fuzzification โ Inference Engine โ Defuzzification โ Output
โ โ
Membership Fuzzy Rules
Functions
- Fuzzification: Converts crisp input values into fuzzy membership degrees
- Rule Base: 8 IF-THEN rules encoding banking expertise
- Inference Engine: Mamdani inference with min-max operations
- Defuzzification: Centroid method for crisp output generation
- Python 3.7 or higher
- pip package manager
- Clone this repository:
git clone https://github.com/yourusername/fuzzy-loan-approval.git
cd fuzzy-loan-approval- Install required packages:
pip install -r requirements.txt- Run the example:
python fuzzy_loan_controller.pyfrom fuzzy_loan_controller import FuzzyLoanController
# Initialize the controller
flc = FuzzyLoanController()
# Define applicant data
applicant = {
'credit_score': 720,
'debt_ratio': 30, # percentage
'income': 75000, # annual income in dollars
'employment_duration': 5 # years
}
# Evaluate the application
result = flc.evaluate_loan_application(applicant)
# Display results
print(f"Decision: {result['decision']}")
print(f"Approval Score: {result['approval_score']}/100")
print(f"Interest Rate: {result['interest_rate']}%")# Visualize all membership functions
flc.visualize_all_membership_functions()
# Visualize complete inference process for an applicant
result = flc.evaluate_loan_application(applicant)
flc.visualize_inference_process(result, "John Doe")| Variable | Range | Linguistic Terms | Description |
|---|---|---|---|
| Credit Score | 300-850 | Poor, Fair, Good, Excellent | FICO score indicating creditworthiness |
| Debt Ratio | 0-100% | Low, Medium, High | Debt-to-Income ratio |
| Annual Income | $0-$200,000 | Low, Medium, High | Yearly earnings |
| Employment Duration | 0-40 years | Short, Medium, Long | Length of continuous employment |
| Variable | Range | Linguistic Terms | Description |
|---|---|---|---|
| Approval Score | 0-100 | Reject, Review, Approve | Continuous approval likelihood |
| Interest Rate | 3-25% | Low, Medium, High | Recommended APR based on risk |
- Score 0-35: REJECTED
- Score 35-70: REQUIRES REVIEW
- Score 70-100: APPROVED
The system uses 8 expert-derived rules:
- Rule 1: IF Credit Score is Excellent AND Debt Ratio is Low โ Approve + Low Interest
- Rule 2: IF Credit Score is Good AND Debt Ratio is Low AND Income is High โ Approve + Low Interest
- Rule 3: IF Credit Score is Good AND Debt Ratio is Medium AND Income is Medium/High โ Approve + Medium Interest
- Rule 4: IF Credit Score is Fair AND Debt Ratio is Low AND Employment is Long โ Review + Medium Interest
- Rule 5: IF Credit Score is Fair AND Debt Ratio is Medium โ Review + Medium Interest
- Rule 6: IF Credit Score is Poor OR Debt Ratio is High โ Reject + High Interest
- Rule 7: IF Income is Low AND Employment is Short โ Reject + High Interest
- Rule 8: IF Credit Score is Excellent AND Debt Ratio is Medium โ Approve + Medium Interest
inputs = {
'credit_score': 780,
'debt_ratio': 15,
'income': 85000,
'employment_duration': 8
}
# Result: APPROVED, Score: 85.88/100, Interest: 5.49%inputs = {
'credit_score': 650,
'debt_ratio': 35,
'income': 50000,
'employment_duration': 3
}
# Result: REQUIRES REVIEW, Score: 52.75/100, Interest: 12.87%inputs = {
'credit_score': 450,
'debt_ratio': 60,
'income': 25000,
'employment_duration': 1
}
# Result: REJECTED, Score: 18.23/100, Interest: 21.05%fuzzy-loan-approval/
โ
โโโ CONTRIBUTING.md # Contribution guide
โโโ fuzzy_loan_controller.py # Main fuzzy logic implementation
โโโ LICENSE # MIT License
โโโ PROJECT_OVERVIEW.md # Project details
โโโ README.md # This file
โโโ requirements.txt # Python dependencies
โโโ setup.py # Installation
|โโ QUICKSTART.md # Quick guide
โโโ .gitignore # Git ignore rules
โ
โโโ docs/ # Documentation
โ โโโ LOAN_APPROVAL_SYSTEM_REPORT.pdf # Detailed technical report
โ
โโโ examples/ # Example scripts
โโโ demo.py # Demonstration script
โโโ test_basic.py # Tests
The system uses both triangular and trapezoidal membership functions:
- Trapezoidal: Used for boundary categories (e.g., "Poor" credit, "Excellent" credit)
- Triangular: Used for middle categories with clear peaks
- Type: Mamdani fuzzy inference
- AND operator: min() function
- OR operator: max() function
- Aggregation: Maximum composition
- Defuzzification: Centroid method (center of gravity)
Centroid Defuzzification Formula:
centroid = ฮฃ(x ร ฮผ(x)) / ฮฃฮผ(x)
Where:
- x = values in the universe of discourse
- ฮผ(x) = aggregated membership function value at x
- Expanded Rule Base: Add more sophisticated scenarios and edge cases
- Adaptive Learning: Implement ANFIS for automatic rule optimization
- Weighted Rules: Allow different rules to have varying importance
- Additional Inputs: Include loan amount, collateral value, payment history
- Web Interface: Build a user-friendly web application
- API Development: Create RESTful API for integration
- Database Integration: Store and analyze historical decisions
- Explainability Dashboard: Enhanced visualization of decision reasoning
This is an academic project, but suggestions and improvements are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Course: SAIA 1193 - Computational Intelligence
Institution: Universiti Teknologi Malaysia (UTM)
Faculty: Faculty of Artificial Intelligence
Semester: 2024/2025-2
Group Members:
- Amina Asyiffa Binti Aspiyah Mahyus (A24AI0015)
- Farin Batrisyia Binti Saipul Nizam (A24AI0030)
- Le Yong Xiang (A24AI0045)
- Muhammad Danish Iqbal Bin Mohamad Hassan (A24AI0052)
- Wan Alif Danial Bin Wan Kamarulfarid (A24AI0093)
- Angraini, N., Rosalina, K., & Kosasih, A. (2024). Optimizing Loan Approval Processes with Support Vector Machines (SVM)
- Sope, D. R., & Fujio, M. (2023). On fuzzification and optimization problems of clustering indices
- Kgatwe, C., et al. (2023). Fuzzy Inference Engine in Condition Monitoring of Industrial Equipment
- Mitsuishi, T. (2022). Definition of Centroid Method as Defuzzification
โญ If you found this project helpful, please consider giving it a star!
For questions or feedback, please open an issue on GitHub.