A Python package for TOPSIS multi-criteria decision analysis
Project description
Topsis-Lakshita-102303505
TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) - A Python package for multi-criteria decision analysis.
What is TOPSIS?
TOPSIS is a multi-criteria decision analysis method that identifies the alternative closest to the ideal solution and farthest from the negative-ideal solution. The ideal solution maximizes benefit criteria and minimizes cost criteria.
Installation
pip install Topsis-Lakshita-102303505
Usage
Command Line
topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
Examples
# Example 1: Equal weights, all positive impacts
topsis data.csv "1,1,1,1,1" "+,+,+,+,+" output.csv
# Example 2: Different weights, mixed impacts
topsis data.csv "2,1,3,1,2" "+,+,-,+,+" results.csv
# Example 3: Using Excel file
topsis data.xlsx "1,1,1,2" "+,+,-,+" output.csv
Python API
from Topsis_Lakshita_102303505 import topsis_analysis
result_df = topsis_analysis(
input_file='data.csv',
weights='1,1,1,2',
impacts='+,+,-,+',
output_file='output.csv'
)
print(result_df)
Input File Format
The input file (CSV or Excel) must have:
- At least 3 columns: 1 name column + 2 or more criteria columns
- First column: Alternative names (text)
- Remaining columns: Numeric criteria values only
Example:
| Model | Price | Storage | Camera | Looks |
|---|---|---|---|---|
| M1 | 250 | 16 | 12 | 5 |
| M2 | 200 | 16 | 8 | 3 |
| M3 | 300 | 32 | 16 | 4 |
Parameters
-
Weights: Comma-separated numeric values (e.g.,
"1,1,1,2")- Must match the number of criteria columns
-
Impacts: Comma-separated
+or-signs (e.g.,"+,+,-,+")+for beneficial criteria (higher is better)-for cost criteria (lower is better)- Must match the number of criteria columns
Output
The output CSV file contains all original columns plus:
- Topsis Score: Performance score (0-1 range, higher is better)
- Rank: Integer ranking (1 = best alternative)
Example Output:
| Model | Price | Storage | Camera | Looks | Topsis Score | Rank |
|---|---|---|---|---|---|---|
| M3 | 300 | 32 | 16 | 4 | 0.691 | 1 |
| M1 | 250 | 16 | 12 | 5 | 0.534 | 2 |
| M2 | 200 | 16 | 8 | 3 | 0.308 | 3 |
Error Handling
The package validates:
- ✅ File existence
- ✅ Minimum 3 columns
- ✅ Numeric values in criteria columns
- ✅ Matching counts of weights, impacts, and criteria
- ✅ Valid impact signs (+ or -)
- ✅ Proper comma separation
Algorithm Steps
- Normalize the decision matrix using vector normalization
- Apply weights to normalized values
- Identify ideal solutions (best and worst)
- Calculate Euclidean distances from ideal solutions
- Compute performance scores
- Rank alternatives based on scores
Dependencies
- pandas >= 1.0.0
- numpy >= 1.18.0
- openpyxl >= 3.0.0 (for Excel support)
License
MIT License - See LICENSE file for details
Author
Lakshita Gupta
Email: lakshitagupta0518@gmail.com
Roll Number: 102303505
Links
- PyPI: https://pypi.org/project/Topsis-Lakshita-102303505/
- GitHub: https://github.com/Lakshita018/topsis
Version
1.0.0 (2026-01-20)
- Initial release
- TOPSIS algorithm implementation
- CSV and Excel file support
- Command-line interface
- Python API
- Comprehensive error handling
For detailed documentation, examples, and troubleshooting, visit the GitHub repository.
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_lakshita_102303505-1.0.0.tar.gz.
File metadata
- Download URL: topsis_lakshita_102303505-1.0.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69bdb5e6877e0e2961b53b9d8fe08d92243118ea3747fd805f87637ba08761b2
|
|
| MD5 |
552da7ba09f2acb21dbd776ccc472dc4
|
|
| BLAKE2b-256 |
ac368c122db12f1ef7ce50860ebfdf2a67d7c2a9872a76bd6960db6e70c0562f
|
File details
Details for the file topsis_lakshita_102303505-1.0.0-py3-none-any.whl.
File metadata
- Download URL: topsis_lakshita_102303505-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3091bc3117532a062b9891a50ec1601c70965e80369095b7a3498400b68b30b5
|
|
| MD5 |
6aa5bbcd6985e2138541f5a69f5d37c5
|
|
| BLAKE2b-256 |
37b4bdb28c38ff079cad8039c8a4d5ad9b2107908bc39f71adc2f57567f0d8a0
|