A Python package to calculate TOPSIS scores
Project description
TOPSIS Package for Multi-Criteria Decision Making
What is TOPSIS?
TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a widely used multi-criteria decision-making (MCDM) method. It ranks alternatives based on their closeness to an ideal solution and their distance from the worst solution.
About This Package
This package provides an easy-to-use implementation of the TOPSIS method for ranking alternatives. It processes a dataset in .csv or .xlsx format and outputs the original dataset with two additional columns: Topsis Score and Rank.
Features:
- Accepts both
.csvand.xlsxinput files. - Automatically converts
.xlsxto.csvif needed. - Validates input data to ensure correctness.
- Handles weighted and impacted criteria for decision-making.
Installation
To install or upgrade to the latest version of this package, use the following command:
pip install --upgrade topsis-102203958
Usage
This package is designed to run as a command-line utility.
Command Syntax:
python topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>
Parameters:
<InputDataFile>: The input file containing the decision matrix (e.g.,data.xlsxordata.csv).<Weights>: A comma-separated list of weights for the criteria (e.g.,1,1,1,2).<Impacts>: A comma-separated list of impacts (+for maximization,-for minimization) (e.g.,+,+,-,+).<ResultFileName>: The name of the output file (e.g.,result.csv).
Example:
Input file data.xlsx:
| Model | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 |
|-------|-------------|-------------|-------------|-------------|
| M1 | 250 | 16 | 12 | 5 |
| M2 | 200 | 20 | 15 | 8 |
| M3 | 300 | 18 | 10 | 6 |
Command:
python topsis data.xlsx "1,1,1,2" "+,+,-,+" result.csv
Output file result.csv:
| Model | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 | Topsis Score | Rank |
|-------|-------------|-------------|-------------|-------------|--------------|------|
| M1 | 250 | 16 | 12 | 5 | 0.672 | 2 |
| M2 | 200 | 20 | 15 | 8 | 0.432 | 3 |
| M3 | 300 | 18 | 10 | 6 | 0.789 | 1 |
Input File Requirements
- The file must contain at least three columns:
- First column: Object/alternative names (e.g., M1, M2, M3).
- Remaining columns: Numeric values only (criteria).
- If the input file is not
.csv, it will be converted to102203958-data.csv. - Weights and impacts must match the number of criteria columns.
Error Handling
The package includes robust error handling for the following scenarios:
- File Not Found: Displays an error if the input file does not exist.
- Incorrect Parameters: Ensures the number of weights, impacts, and criteria columns match.
- Non-Numeric Values: Verifies that all criteria columns contain numeric values only.
- Invalid Impacts: Checks that impacts are either
+or-.
License
This package is distributed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Feel free to fork the repository, make changes, and submit a pull request.
For major changes, please open an issue first to discuss what you would like to change.
Check out the repository here: GitHub Repository
Support
If you encounter any issues or have questions, please open an issue on the GitHub repository or contact the package maintainer.
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-102203958-1.0.8.tar.gz.
File metadata
- Download URL: topsis-102203958-1.0.8.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d53fb3db92396d507701a8eb88eed44a48bd5bbcc93aa17bbcdf7665c30c25fa
|
|
| MD5 |
dfe8edf6fd62a867d990ae3cabb74049
|
|
| BLAKE2b-256 |
77ecaf8f2b53666da707c29e26a440d4d8ce9b137fddc15f8f2991f0da6785c2
|
File details
Details for the file topsis_102203958-1.0.8-py3-none-any.whl.
File metadata
- Download URL: topsis_102203958-1.0.8-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.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc973bee8f3065fabff94759c8783a18c82692f37dc5ab260741c2525b2ceded
|
|
| MD5 |
9aec381a9193d986354be18de915a312
|
|
| BLAKE2b-256 |
9c8960a0101a0ca5c69138d30448d5df4e0a5de5dbb5bb914a146932c97445af
|