A Python implementation of the TOPSIS decision-making method
Project description
TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution)
TOPSIS is a Python library for implementing the Technique for Order of Preference by Similarity to Ideal Solution, a multi-criteria decision-making method. This library allows users to rank alternatives based on given criteria, weights, and impacts.
Installation
You can install the library via pip:
pip install Topsis-102396003
Usage
Command-line Usage
The library can be used directly from the command line. Here's the general syntax:
python <program.py>
Example
Create an input file, data.csv:
Name,C1,C2,C3,C4 A,250,16,12,5 B,200,32,8,3 C,300,24,10,4 D,275,20,11,4 E,225,28,9,2
Run the command:
python topsis.py data.csv "0.25,0.25,0.25,0.25" "+,+,-,+" result.csv
The output result.csv will contain:
Name,C1,C2,C3,C4,Topsis Score,Rank A,250,16,12,5,0.64,2 B,200,32,8,3,0.43,4 C,300,24,10,4,0.78,1 D,275,20,11,4,0.56,3 E,225,28,9,2,0.36,5
Python Library Usage
Importing the Library
You can also use the library directly in Python:
from topsis import Topsis
Input data
data = "data.csv" weights = [0.25, 0.25, 0.25, 0.25] impacts = ["+", "+", "-", "+"] result_file = "result.csv"
Perform TOPSIS
Topsis(data, weights, impacts, result_file) print(f"Results saved in {result_file}")
Parameters
InputDataFile: A CSV file with the first column as the name of the alternatives and the rest as numeric criteria.
Weights: A comma-separated string of numeric weights (e.g., "0.25,0.25,0.25,0.25").
Impacts: A comma-separated string of impacts for each criterion, either + (positive impact) or - (negative impact).
ResultFileName: The name of the output CSV file where results will be saved.
Features
Validate input file format and values.
Handle missing or invalid values gracefully.
Normalize and weight criteria.
Calculate TOPSIS scores and rankings.
Limitations
All criteria must be numeric.
The number of weights and impacts must match the number of criteria.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Feel free to open issues or create pull requests to improve the library!
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_102396003-1.0.0.tar.gz.
File metadata
- Download URL: topsis_102396003-1.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d40ca3c14f1fa9b56312dafd9f688b0a1107f9a94edc7ea226b44b526ff08794
|
|
| MD5 |
50fc4106ca55a46f37aa3f49dd8b7894
|
|
| BLAKE2b-256 |
3848c8aa3c78faf5bdbe4d290e95affcbe388d133a519aac21ea10da2d7f10d2
|
File details
Details for the file Topsis_102396003-1.0.0-py3-none-any.whl.
File metadata
- Download URL: Topsis_102396003-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bf6d83461307f126b132a0068254f985e8448bdacc3406ab5b8792a765583ea
|
|
| MD5 |
807f331b53e9d6829ece13e2526be549
|
|
| BLAKE2b-256 |
01667caa4da76188a7297b2dfc60101ff0f63ca758b6e7ffbe9b2570c1b8d614
|