A Python package to perform TOPSIS analysis for multi-criteria decision making
Project description
TOPSIS Implementation in Python
A simple command-line tool and Python package for performing TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) analysis on multi-criteria decision-making problems.
What is TOPSIS?
TOPSIS is a method used to find the best alternative from a set of options based on multiple criteria. It works by:
- Normalizing the decision matrix
- Applying weights to criteria
- Finding ideal best and worst solutions
- Calculating distances from these ideal points
- Ranking alternatives based on relative closeness to the ideal best
Installation
You can install this package using pip:
pip install Topsis-Naman-102317144
Usage
Command Line
After installation, you can use the topsis command directly from terminal:
topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>
Example:
topsis data.csv "1,1,1,1,1" "+,+,-,+,+" result.csv
Python Package
You can also import and use it in your Python code:
from Topsis_Naman_102317144 import run_topsis
# Run TOPSIS analysis
run_topsis('data.csv', '1,1,1,1,1', '+,+,-,+,+', 'result.csv')
Input File Format
The input file should be a CSV or Excel file with:
- First column: Name/ID of alternatives
- Remaining columns: Criteria values (numeric only)
Example (data.csv):
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
Parameters
-
Weights: Comma-separated numbers representing importance of each criterion
- Example: "1,1,1,2" means 4 criteria with last one having double weight
-
Impacts: Comma-separated + or - signs
+means higher value is better (benefit criteria)-means lower value is better (cost criteria)- Example: "+,+,-,+,+" means 3rd criterion is cost, others are benefits
Output
The program generates a CSV file with:
- All original columns
- Topsis Score: Calculated score for each alternative
- Rank: Ranking based on TOPSIS score (1 is best)
Error Handling
The program checks for:
- Correct number of parameters
- File existence
- Minimum 3 columns in input
- Numeric values in criteria columns
- Matching count of weights, impacts, and criteria
- Valid impact values (+ or -)
Example
# Install the package
pip install Topsis-Naman-102317144
# Run TOPSIS
topsis input.csv "1,2,1,1" "+,-,+,+" output.csv
Requirements
- Python 3.6+
- pandas
- numpy
License
MIT License - feel free to use this for your projects!
Author
Naman Singh (Roll: 102317144)
Version
1.0.3
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_naman_102317144-1.0.3.tar.gz.
File metadata
- Download URL: topsis_naman_102317144-1.0.3.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af53410022594c8a2ca2fe2d2a5a77decdd715a1eef2d5558348480f1e451441
|
|
| MD5 |
e62ca4b1cde8960994bf6f621e279978
|
|
| BLAKE2b-256 |
d731e5d858a389abdf94fca51f381dfa55a54b170d83f7368933627e8d476a70
|
File details
Details for the file topsis_naman_102317144-1.0.3-py2.py3-none-any.whl.
File metadata
- Download URL: topsis_naman_102317144-1.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21339b366174b826cd2cecc3861f01c701eda09a445e76361164065aa334b5a9
|
|
| MD5 |
34ee27e0dfaf75c30e5c5182633d07e1
|
|
| BLAKE2b-256 |
969d3964d48c1606b41829400380977078732e5211b15bba55655158d4a45130
|