Multiple criteria decision making for selection of best model
Project description
TOPSIS Implementation in Python
About TOPSIS
TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a multi-criteria decision analysis method which was originally developed by Hwang and Yoon in 1981. TOPSIS chooses the alternative that is the closest to the positive ideal solution and farthest from the negative ideal solution.
Installation
pip install topsis
Usage
The program accepts the following arguments:
- Input file (.csv)
- Weights (comma-separated)
- Impacts (comma-separated)
- Output file (.csv)
python topsis.py input.csv "1,1,1,2,2" "+,-,-,+,-" output.csv
Input File Format
Input file must contain three or more columns:
- First column: Object/Variable name
- Second to last columns: Criteria values
- File must be a CSV file (.csv extension)
Sample input file:
Fund Name,P1,P2,P3,P4,P5
M1,0.68,0.48,13.07,0.74,0.87
M2,0.78,0.61,14.85,0.71,0.29
M3,0.61,0.37,14.01,0.71,0.95
M4,0.76,0.39,11.11,0.77,0.14
M5,0.59,0.41,11.32,0.82,0.55
Output Format
Output file contains all the columns of input file along with two additional columns having normalized scores and ranks.
Sample output file:
Fund Name,P1,P2,P3,P4,P5,Topsis Score,Rank
M1,0.68,0.48,13.07,0.74,0.87,0.7722,2
M2,0.78,0.61,14.85,0.71,0.29,0.6253,4
M3,0.61,0.37,14.01,0.71,0.95,0.8231,1
M4,0.76,0.39,11.11,0.77,0.14,0.5486,5
M5,0.59,0.41,11.32,0.82,0.55,0.6791,3
Parameters
Weights
Weights indicate the relative importance of each criterion. They should be provided as comma-separated values. Number of weights should be equal to number of criteria.
Example: "1,1,1,2,2"
Impacts
Impacts decide whether the criterion is to be maximized (+) or minimized (-). They should be provided as comma-separated values. Number of impacts should be equal to number of criteria.
Example: "+,-,-,+,-"
Error Handling
The program handles the following errors:
- Input file does not exist
- Input file is not a CSV file
- Input file has less than 3 columns
- Number of weights, impacts is not equal to number of criteria
- Impacts are not either '+' or '-'
- Non-numeric values in criteria columns
Example
Consider a real estate decision problem with the following criteria:
- Cost (-)
- Square footage (+)
- Distance to city center (-)
- Age of building (-)
- Number of rooms (+)
python topsis.py houses.csv "0.25,0.25,0.15,0.15,0.20" "-,+,-,-,+" output.csv
Dependencies
- Python 3.x
- Pandas
- NumPy
License
This project is licensed under MIT License - see the LICENSE file for details.
Contributing
- Fork the repository
- Create your 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
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_parth_102203636-1.0.0.tar.gz.
File metadata
- Download URL: topsis_parth_102203636-1.0.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96d81856391afc91d5098cb415d39126013db8217e5b27c2026461972b74ad7c
|
|
| MD5 |
3db3c77c541b9eb4208882e736a99bb4
|
|
| BLAKE2b-256 |
5f2b2e3b998d0d857d23510ff0ed6ece17a47035e2edd5379a047796486d1a70
|
File details
Details for the file Topsis_Parth_102203636-1.0.0-py3-none-any.whl.
File metadata
- Download URL: Topsis_Parth_102203636-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc44b2abac762c1107bf3d1bdaf604b1599efab749ba3576bf52e075797eca4f
|
|
| MD5 |
6d5f8ec5c5e4bdc9b84431cfe5851513
|
|
| BLAKE2b-256 |
5b03ffc61f8c170713e2247231eb08ec7e5cadf1c1774a4168195cf312fdaa7f
|