A Python package for TOPSIS multi-criteria decision making method
Project description
TOPSIS — Khushi (102303610)
Topsis-Khushi-102303610 is a Python library for solving Multiple Criteria Decision Making (MCDM) problems using the Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS).
What is TOPSIS?
TOPSIS is a decision-making method used when you need to choose the best option from several alternatives based on multiple criteria.
Core Concept
The best alternative should have:
- The shortest distance from the Positive Ideal Solution (best possible values)
- The longest distance from the Negative Ideal Solution (worst possible values)
Simple Example
Imagine choosing a mutual fund based on:
- P1 (higher is better) ✓
- P2 (higher is better) ✓
- P3 (lower is better) ✗
- P4 (higher is better) ✓
TOPSIS calculates a score for each fund and ranks them to help you pick the best one!
Features
- ✅ Simple command-line interface
- ✅ Handles any number of alternatives and criteria
- ✅ Automatic normalization of data
- ✅ Supports both beneficial (+) and non-beneficial (-) criteria
- ✅ Generates ranked output with TOPSIS scores
- ✅ Easy to install and use
Installation
Install the package using pip:
pip install Topsis-Khushi-102303610
Usage
Run TOPSIS from the command line:
topsis <InputFile.csv> <Weights> <Impacts> <OutputFile.csv>
Method 1: With Quotes (Recommended)
topsis data.csv "1,1,1,1" "+,+,-,+" result.csv
Method 2: Without Quotes
topsis data.csv 1,1,1,1 +,+,-,+ result.csv
Important:
Method 2 does not allow spaces. Always use quotes if there are spaces in your input.
Get Help
topsis -h
Input File Format
The input must be a CSV file with the following structure:
Requirements
- First column: Names or IDs of alternatives (text)
- Remaining columns: Numerical criteria values only
- First row: Column headers
Example: data.csv
Fund Name,P1,P2,P3,P4
M1,0.67,0.45,6.5,42.6
M2,0.6,0.36,3.6,53.3
M3,0.82,0.67,3.8,63.1
M4,0.6,0.36,3.5,69.2
Where:
Fund Name= Name of the mutual fundP1, P2, P3, P4= Different performance criteria to evaluate
Example
Input File: data.csv
Fund Name,P1,P2,P3,P4
M1,0.67,0.45,6.5,42.6
M2,0.6,0.36,3.6,53.3
M3,0.82,0.67,3.8,63.1
M4,0.6,0.36,3.5,69.2
Command
topsis data.csv "0.25,0.25,0.25,0.25" "+,+,-,+" output.csv
Parameters Explained
| Parameter | Value | Meaning |
|---|---|---|
| Weights | 0.25,0.25,0.25,0.25 |
All criteria have equal importance (25% each) |
| Impacts | +,+,-,+ |
P1 ✓, P2 ✓, P3 ✗, P4 ✓ |
Impacts:
+means higher is better (beneficial)-means lower is better (non-beneficial)
Output: output.csv
Fund Name,P1,P2,P3,P4,Topsis Score,Rank
M1,0.67,0.45,6.5,42.6,0.448532,3
M2,0.6,0.36,3.6,53.3,0.532891,2
M3,0.82,0.67,3.8,63.1,0.691876,1
M4,0.6,0.36,3.5,69.2,0.589247,2
Result: Fund M3 is ranked 1st (best choice) with the highest TOPSIS Score.
Input Validation Rules
The package validates your input to ensure correctness:
| Rule | Description |
|---|---|
| ✓ File format | Must be a .csv file |
| ✓ Minimum alternatives | At least 2 rows of data |
| ✓ Minimum criteria | At least 2 criteria columns |
| ✓ Numeric values | All criteria values must be numbers |
| ✓ Matching counts | Number of weights = Number of impacts = Number of criteria |
| ✓ Valid impacts | Only + or - allowed |
| ✓ Positive weights | All weights must be > 0 |
How TOPSIS Works (Algorithm)
- Normalize the decision matrix
- Calculate the weighted normalized matrix
- Determine the Ideal Best (positive ideal solution)
- Determine the Ideal Worst (negative ideal solution)
- Calculate Euclidean distances from ideal best and worst
- Compute TOPSIS performance score for each alternative
- Rank alternatives (1 = best)
Error Handling
Common errors and solutions:
| Error | Cause | Solution |
|---|---|---|
| File not found | Wrong file path | Check the file name and path |
| Wrong number of parameters | Mismatch in counts | Ensure weights, impacts, and criteria match |
| Non-numeric values | Text in criteria columns | All criteria must be numbers (except first column) |
| Invalid impact | Wrong symbol used | Use only + or - |
| Invalid weights | Zero or negative weight | All weights must be positive numbers |
Package Information
Author: Khushi
Roll Number: 102303610
Institution: Thapar Institute of Engineering and Technology
Version: 1.0.0
License: MIT
Keywords
TOPSIS, MCDM, Multi-Criteria Decision Making, Decision Analysis, Optimization, Python, Data Science, Operations Research
For any issues or questions, please refer to the package documentation or contact the author.
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_khushi_102303610-1.0.0.tar.gz.
File metadata
- Download URL: topsis_khushi_102303610-1.0.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7d6e37f747737dca87f7d558b3742be73944e1f2349e8086ec47afc03a7165d
|
|
| MD5 |
d179770c14e67c76e2218a73bde954ab
|
|
| BLAKE2b-256 |
2d883448f1c8cba08026642754e83d1c8ca14a7b2fa9f68135120f84e36957cb
|
File details
Details for the file topsis_khushi_102303610-1.0.0-py3-none-any.whl.
File metadata
- Download URL: topsis_khushi_102303610-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
134a365ffa3c0503b4612c740dac716600a60eaeca1184afd585366c720062a0
|
|
| MD5 |
e83cc6f8399f5bc463407d5de8e97b2b
|
|
| BLAKE2b-256 |
d03cd5836421e33a8016530e3eba57f0fde6b013ceafd2434afe2c2152aef33f
|