TOPSIS Method for Multi-Criteria Decision Making
Project description
Topsis-Shubham-102316044
TOPSIS — Technique for Order of Preference by Similarity to Ideal Solution
A Multi-Criteria Decision Making (MCDM) method for ranking alternatives.
Installation
pip install Topsis-shubham-102316044
Command Line Usage
topsis <InputFile> <Weights> <Impacts> <OutputFile>
Example
topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
Python API Usage
from topsis_pkg import run_topsis
run_topsis(
input_file = "data.csv",
weights = "1,1,1,2",
impacts = "+,+,-,+",
output_file = "result.csv"
)
Input File Format
Your CSV must have:
- Column 1: Alternative names (text)
- Columns 2 to last: Numeric criteria values
Example data.csv
| Fund | Return | Risk | Expense | Liquidity |
|---|---|---|---|---|
| M1 | 0.94 | 0.88 | 6.3 | 40.0 |
| M2 | 0.76 | 0.58 | 7.0 | 45.2 |
| M3 | 0.93 | 0.86 | 3.4 | 60.6 |
Parameters
Weights
Comma-separated positive numbers — one per criterion column.
"1,1,1,2" means the 4th criterion is twice as important.
Impacts
Comma-separated + or - — one per criterion column.
| Symbol | Meaning | Example |
|---|---|---|
+ |
Higher value is better (benefit) | Return, Score, Quality |
- |
Lower value is better (cost) | Expense, Risk, Price |
Output
The result CSV contains all original columns plus two new ones:
| Column | Description |
|---|---|
Topsis Score |
Score from 0 to 1. Higher = closer to ideal best |
Rank |
1 = best alternative |
Example Output
| Fund | Return | Risk | Expense | Liquidity | Topsis Score | Rank |
|---|---|---|---|---|---|---|
| M1 | 0.94 | 0.88 | 6.3 | 40.0 | 0.7542 | 1 |
| M3 | 0.93 | 0.86 | 3.4 | 60.6 | 0.6218 | 2 |
| M2 | 0.76 | 0.58 | 7.0 | 45.2 | 0.3782 | 3 |
Validations
The package checks for:
- Correct number of command-line parameters
- File existence (
FileNotFoundErrorwith clear message) - Minimum 3 columns in input file
- Numeric values in criteria columns
- Matching count of weights, impacts, and columns
- Valid impact values (
+or-only) - Comma-separated format for weights and impacts
Algorithm Steps
- Normalize the decision matrix (Euclidean norm)
- Weight the normalized matrix
- Find Ideal Best (V⁺) and Ideal Worst (V⁻)
- Calculate separation distances (d⁺ and d⁻)
- Compute performance score:
P = d⁻ / (d⁺ + d⁻) - Rank by descending score
License
MIT License — see LICENSE
Author
Shubham — shubham_be23@thapar.edu
GitHub · PyPI
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_shubham_102316044-1.0.2.tar.gz.
File metadata
- Download URL: topsis_shubham_102316044-1.0.2.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f151aa259937522604e334cf3759b9742bcfefcf4d78df206810db9977b9fc4c
|
|
| MD5 |
c06dded29b72b98726e6634c8e54af6c
|
|
| BLAKE2b-256 |
3b8f2d33030d7823faebdd4d3a4bdb6a8f65411ab733a418f20541ce86c8eb1e
|
File details
Details for the file topsis_shubham_102316044-1.0.2-py3-none-any.whl.
File metadata
- Download URL: topsis_shubham_102316044-1.0.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e5219ede4f6665052b22dd445f169984c78e5dd2f72a24be41f68f11b9e6f6d
|
|
| MD5 |
77f0ad544f7cf37ea6089aa54f23fd93
|
|
| BLAKE2b-256 |
5520ff3dac94822c24004ebb7d1ca43fa2defb057ac96079fbccdfff364ad528
|