A Python package for TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) analysis
Project description
TOPSIS-YourName-RollNumber
TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) - A Python package for multi-criteria decision analysis.
📋 Description
TOPSIS is a multi-criteria decision-making method that helps rank alternatives based on their similarity to the ideal solution. This package provides an easy-to-use implementation of the TOPSIS algorithm with comprehensive error handling and validation.
🎯 Features
- ✅ Complete TOPSIS algorithm implementation
- ✅ Command-line interface
- ✅ Comprehensive input validation
- ✅ Detailed error messages
- ✅ CSV input/output support
- ✅ Easy to use and integrate
📦 Installation
From PyPI
pip install Topsis-YourName-RollNumber
From Source
git clone https://github.com/yourusername/Topsis-YourName-RollNumber.git
cd Topsis-YourName-RollNumber
pip install -e .
🚀 Usage
Command Line
python -m Topsis-YourName-RollNumber <InputFile> <Weights> <Impacts> <OutputFile>
Example
python -m Topsis-YourName-RollNumber data.xlsx "1,1,1,2" "+,+,-,+" output.xlsx
As a Python Module
from Topsis_YourName_RollNumber import topsis_analysis
# Perform TOPSIS analysis
result_df = topsis_analysis(
input_file='data.xlsx',
weights='1,1,1,2',
impacts='+,+,-,+',
output_file='output.xlsx'
)
print(result_df)
📊 Input Format
Excel File Requirements (.xlsx)
- Minimum 3 columns: First column for alternatives (names), remaining columns for numeric criteria
- First column: Alternative names (non-numeric)
- Remaining columns: Numeric values only
Example Input File (data.xlsx)
| Fund Name | P1 | P2 | P3 | P4 | P5 |
|---|---|---|---|---|---|
| M1 | 0.84 | 0.71 | 6.7 | 42.1 | 12.59 |
| M2 | 0.91 | 0.83 | 7.0 | 31.7 | 10.11 |
| M3 | 0.79 | 0.62 | 4.8 | 46.7 | 13.23 |
| M4 | 0.78 | 0.61 | 6.4 | 42.4 | 12.55 |
| M5 | 0.94 | 0.88 | 3.6 | 62.2 | 16.91 |
Parameters
- Weights: Comma-separated numeric values (e.g.,
"1,1,1,2") - Impacts: Comma-separated
+or-signs (e.g.,"+,+,-,+")+: Benefit criterion (higher is better)-: Cost criterion (lower is better)
📤 Output Format
The output Excel file contains all input columns plus:
- Topsis Score: Performance score (0-1, higher is better)
- Rank: Ranking (1 = best alternative)
Example Output
| Fund Name | P1 | P2 | P3 | P4 | P5 | Topsis Score | Rank |
|---|---|---|---|---|---|---|---|
| M5 | 0.94 | 0.88 | 3.6 | 62.2 | 16.91 | 0.6890 | 1 |
| M8 | 0.93 | 0.87 | 5.5 | 53.3 | 15.07 | 0.6123 | 2 |
| ... | ... | ... | ... | ... | ... | ... | ... |
⚠️ Error Handling
The package validates:
- ✅ Correct number of arguments
- ✅ File existence
- ✅ Excel format (.xlsx)
- ✅ Minimum 3 columns
- ✅ Numeric values in criteria columns
- ✅ Matching number of weights and criteria
- ✅ Matching number of impacts and criteria
- ✅ Valid impact signs (+ or -)
- ✅ Proper comma separation
🧮 TOPSIS Algorithm Steps
- Normalize the decision matrix
- Apply weights to normalized matrix
- Identify ideal best and ideal worst solutions
- Calculate Euclidean distances from ideal solutions
- Compute TOPSIS score
- Rank alternatives
📚 Mathematical Formula
TOPSIS Score:
$$P_i = \frac{S_i^-}{S_i^+ + S_i^-}$$
Where:
- $S_i^+$ = Distance from ideal best
- $S_i^-$ = Distance from ideal worst
🛠️ Requirements
- Python >= 3.7
- pandas >= 1.0.0
- numpy >= 1.18.0
- openpyxl >= 3.0.0
📄 License
MIT License
👤 Author
Your Name
- Roll Number: Your Roll Number
- Email: your.email@example.com
- GitHub: @yourusername
🤝 Contributing
Contributions, issues, and feature requests are welcome!
📝 Changelog
Version 1.0.0 (Initial Release)
- Complete TOPSIS implementation
- CLI interface
- Comprehensive validation
- PyPI package
Made with ❤️ for Multi-Criteria Decision Making
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file topsis_vaibhavi_102303784-1.0.0.tar.gz.
File metadata
- Download URL: topsis_vaibhavi_102303784-1.0.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8beed2ee8835416d371388bbbca2b381fe7c8c12511db75e2d5956ae4e442f5f
|
|
| MD5 |
0c1d1d330e4e7d1a5b9f0ddbd2dbdeb5
|
|
| BLAKE2b-256 |
e98aa79423c2cc836637dac1dbeae7dc6c9db647d024e6d9cfdc961de8852940
|
File details
Details for the file topsis_vaibhavi_102303784-1.0.0-py3-none-any.whl.
File metadata
- Download URL: topsis_vaibhavi_102303784-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a141e2a4e25178909bc055735224baccf93934f9528242916bd6fc71b6cc408
|
|
| MD5 |
2c939ce75caeae3794b719d823adf33c
|
|
| BLAKE2b-256 |
18d96599ed0b5f1d6eebde222441be47023b84c46592b311ebf7a5a2166819eb
|