It does the mathematics of topsis
Project description
TOPSIS Python Package
Overview
TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a widely used multi-criteria decision analysis (MCDA) method. It helps in ranking and selecting alternatives based on a set of criteria, where each criterion may have varying importance (weight) and impact (positive or negative).
This package implements the TOPSIS method, which can be used to rank options based on input data, weights, and impacts for each criterion. The results include a ranking, the distance to the ideal best and worst solutions, and the TOPSIS score for each option.
Features
- Ranking: Ranks options based on a set of criteria.
- Flexible Inputs: Allows users to specify weights and impacts for each criterion.
- Ideal Solution Calculation: Computes the distance from both the ideal best and worst solutions.
- CSV Input and Output: Accepts CSV files for input and generates CSV files for results.
Installation
To install the topsis package, run the following command in your terminal:
pip install topsis-package
Usage
Command-Line Usage
After installing the package, you can run the TOPSIS method from the command line using the following syntax:
python -m topsis.topsis input_data.csv "1,1,2,2,1" "+,+,-,-,-" result.csv
Parameters
The command-line tool accepts the following parameters:
-
input_data.csv(Required):- Path to the input CSV file containing the data.
- The first column of the CSV file should represent the options (e.g., Option1, Option2, ...).
- The remaining columns should contain the criteria values for each option.
-
"1,1,2,2,1"(Required):- A comma-separated string representing the weights for each criterion.
- Each number corresponds to the importance of a criterion. The higher the number, the more important the criterion is.
-
"+,+,-,-,-"(Required):- A comma-separated string representing the impacts for each criterion.
- The impacts can be either:
+for positive impact: A higher value for the criterion is better.-for negative impact: A lower value for the criterion is better.
-
result.csv(Required):- Path to the output CSV file where the results will be saved.
- The output file will contain the following columns:
- Option: The option name.
- Distance from Ideal Best: The Euclidean distance of each option from the best possible solution.
- Distance from Ideal Worst: The Euclidean distance of each option from the worst possible solution.
- TOPSIS Score: A score that indicates how close each option is to the ideal solution.
- Rank: The rank of each option based on its TOPSIS score (1 being the best).
Example
Input CSV: input_data.csv
Option,Criterion1,Criterion2,Criterion3,Criterion4,Criterion5
Option1,7,9,6,8,7
Option2,8,7,9,7,8
Option3,6,5,8,6,5
Syntax
To use the TOPSIS method, run the following command in the terminal:
python -m topsis.topsis <input_data.csv> <weights> <impacts> <result.csv>
Output CSV: result.csv
The output of the TOPSIS method is saved in a CSV file named result.csv with the following structure:
Option,Distance from Ideal Best,Distance from Ideal Worst,TOPSIS Score,Rank
Option1,2.5,5.0,0.6667,1
Option2,3.0,4.5,0.6,2
Option3,3.5,3.0,0.4615,3
Understanding the Output
-
Distance from Ideal Best:
- Euclidean distance of each option from the best possible solution. The ideal best solution is the one that has the maximum value in all positive impact criteria and the minimum in all negative impact criteria.
-
Distance from Ideal Worst:
- Euclidean distance of each option from the worst possible solution. The ideal worst solution is the one that has the minimum value in all positive impact criteria and the maximum in all negative impact criteria.
-
TOPSIS Score:
- The score that indicates how close each option is to the ideal solution. A higher score means the option is closer to the ideal solution.
-
Rank:
- The ranking of each option based on its TOPSIS score (1 being the best).
License
© 2025 Lakshit Gupta
This repository is licensed under the MIT license. See LICENSE for details.
Additional Notes
- The package requires Python 3.6 or higher.
- Ensure the input data is clean and contains only numerical values for the criteria columns.
- The package works with CSV files where the first column contains options (e.g., Option1, Option2, etc.) and the remaining columns contain numerical values representing the criteria.
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_lakshit_102203222-1.0.0.tar.gz.
File metadata
- Download URL: topsis_lakshit_102203222-1.0.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92e6ae731af361839a3d71e65dd7cff7fbba137b66ab2a6b5154a8c1e2d21bf2
|
|
| MD5 |
0abcf01baa89831e29b9d5914cfcb400
|
|
| BLAKE2b-256 |
9fce2ab40f72ad6704414562638e12ab98235fb3c27f8c283b154e0fb86ffc51
|
File details
Details for the file Topsis_Lakshit_102203222-1.0.0-py3-none-any.whl.
File metadata
- Download URL: Topsis_Lakshit_102203222-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5375d3330876a0e0135c66959a8b303b0b7a115c73e1bec51e3eeb32bc2d4b06
|
|
| MD5 |
b754e0458f56698eb0ffc764faeef58d
|
|
| BLAKE2b-256 |
c74165c16def21e94c31a36bd4539d91bcd5a1f5aee6dad127c2c0c278f0c615
|