TOPSIS CLI tool
Project description
TOPSIS Package
Project description
TOPSIS Implementation
Overview
This Python package provides a straightforward implementation of the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) method for multi-criteria decision-making. With this tool, you can rank alternatives based on multiple criteria using weights and impacts for each criterion.
Features
- Easy-to-use command-line interface.
- Supports customizable weights and impacts for criteria.
- Outputs a ranked list of alternatives with TOPSIS scores.
- Handles CSV input and output for seamless integration with data workflows.
Usage
Command-Line Interface
To execute TOPSIS, use the following command:
python topsis.py <input_file> <weights> <impacts> <output_file>
Arguments
<input_file>: Path to the CSV file containing the input data. The first column should contain alternative names, and subsequent columns should contain numerical criteria values.<weights>: Comma-separated weights for each criterion (e.g., 1,2,3).<impacts>: Comma-separated impacts for each criterion (+ for benefit criteria, - for cost criteria, e.g., +, +, -, +).<output_file>: Path to the CSV file where the results will be saved.
Example
Suppose you have the following input file (data.csv):
| Alternative | Criterion 1 | Criterion 2 | Criterion 3 |
|---|---|---|---|
| A1 | 250 | 16 | 12 |
| A2 | 200 | 20 | 8 |
| A3 | 300 | 12 | 15 |
| A4 | 275 | 14 | 10 |
To rank the alternatives with weights 1,1,1 and impacts +,+,-, run:
python topsis.py data.csv 1,1,1 +,+,- results.csv
The output (results.csv) will include the TOPSIS scores and ranks:
| Alternative | Criterion 1 | Criterion 2 | Criterion 3 | Topsis Score | Rank |
|---|---|---|---|---|---|
| A1 | 250 | 16 | 12 | 0.6547 | 2 |
| A2 | 200 | 20 | 8 | 0.3001 | 4 |
| A3 | 300 | 12 | 15 | 0.8234 | 1 |
| A4 | 275 | 14 | 10 | 0.4921 | 3 |
Input File Requirements
- The input file must be a CSV with at least three columns.
- The first column should contain the names of the alternatives.
- The remaining columns should contain numerical values for criteria.
Output File
The output file will contain the original data along with two additional columns:
Topsis Score: The calculated TOPSIS score for each alternative.Rank: The rank of each alternative based on the TOPSIS score (1 = best).
Error Handling
The package validates inputs and raises errors for:
- Input files with fewer than three columns.
- Mismatched lengths of weights or impacts compared to the criteria.
- Invalid impact values (must be + or -).
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
Contact
For questions or feedback, please contact mrinankjit@gmail.com.
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_mrinank_102303235-0.0.1.tar.gz.
File metadata
- Download URL: topsis_mrinank_102303235-0.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4397b55e67058136f6c0f6992431aa8e968adcc383043439c1acacbc368010b8
|
|
| MD5 |
a9955d7fadb5728d3d9028fff09f8ad4
|
|
| BLAKE2b-256 |
cc678283de1f2d73ec11613128298c216221f7cf694611ec598de3f37783c12c
|
File details
Details for the file topsis_mrinank_102303235-0.0.1-py3-none-any.whl.
File metadata
- Download URL: topsis_mrinank_102303235-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7297a430c609839e14d8a9f9c3795799b35e65dde0440a0a652170fce3c202ba
|
|
| MD5 |
f255f393cad9ad74324247e7877b6fe2
|
|
| BLAKE2b-256 |
297a2a5994c8068ce831c007a137cf4324c2a93ee1ade0511c6efe7c9a881d7f
|