TOPSIS implementation as a Python package
Project description
Topsis-Aastha-102313059
This Python package implements the TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) method for solving multi-criteria decision-making problems.
It ranks alternatives based on their performance across multiple criteria.
Introduction
In many real-world problems, decisions depend on multiple factors such as cost, performance, risk, and return.
TOPSIS is a popular multi-criteria decision-making technique that identifies the best alternative by comparing distances from an ideal best and ideal worst solution.
The best alternative is:
- Closest to the positive ideal solution
- Farthest from the negative ideal solution
TOPSIS Methodology
The TOPSIS approach consists of the following steps:
Step 1: Construct Decision Matrix
List alternatives and their performance under each criterion.
Step 2: Normalize the Matrix
rij = xij / √(∑xij²)
This removes scale differences among criteria.
Step 3: Weighted Normalized Matrix
vij = wj × rij
Step 4: Determine Ideal Solutions
Positive ideal solution = best values
Negative ideal solution = worst values
(based on benefit (+) or cost (−) criteria)
Step 5: Distance Calculation
Euclidean distance from ideal best and worst is calculated.
Step 6: TOPSIS Score
Score = Distance from worst / (Distance from best + Distance from worst)
Step 7: Ranking
Higher score indicates better alternative.
Input Data Format
The Excel input file must contain:
| Fund Name | P1 | P2 | P3 | P4 | P5 |
|---|---|---|---|---|---|
| Fund A | |||||
| Fund B |
- First column contains alternatives
- Remaining columns contain numeric criteria values
Result Table (Sample Output)
| Fund Name | P1 | P2 | P3 | P4 | P5 | Topsis Score | Rank |
|---|---|---|---|---|---|---|---|
| M1 | 0.84 | 0.71 | 6.7 | 42.1 | 12.59 | 0.382109 | 6 |
| M2 | 0.91 | 0.83 | 7.0 | 31.7 | 10.11 | 0.366492 | 7 |
| M3 | 0.79 | 0.62 | 4.8 | 46.7 | 13.23 | 0.496361 | 4 |
| M4 | 0.78 | 0.61 | 6.4 | 42.4 | 12.55 | 0.324792 | 8 |
| M5 | 0.94 | 0.88 | 3.6 | 62.2 | 16.91 | 0.972128 | 1 |
| M6 | 0.88 | 0.77 | 6.5 | 51.5 | 14.91 | 0.547048 | 3 |
| M7 | 0.66 | 0.44 | 5.3 | 48.9 | 13.83 | 0.395015 | 5 |
| M8 | 0.93 | 0.86 | 3.4 | 37.0 | 10.55 | 0.560092 | 2 |
The results show that Fund M5 achieved the highest TOPSIS score and is ranked as the best alternative.
Result Visualization
The TOPSIS scores can be visualized using a bar graph to compare the performance of alternatives.
- X-axis: Fund Names
- Y-axis: TOPSIS Scores
This provides a clear comparison of rankings.
Installation
Install the package using:
pip install Topsis-Aastha-102313059
Usage
Run the package from command line:
topsis <InputFile> <Weights> <Impacts> <OutputFile>
### Example:
topsis data.xlsx "1,1,1,1,1" "+,+,-,+,+" result.csv
---
## Requirements
- pandas
- numpy
- openpyxl
---
## Conclusion
This package offers a simple and efficient implementation of the TOPSIS decision-making technique and can be used for financial analysis, performance evaluation, and other multi-criteria decision problems.
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_aastha_102313059-1.0.1.tar.gz.
File metadata
- Download URL: topsis_aastha_102313059-1.0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
730b4ddebdffd8c1fac0436ae5fa24a2f4de03c07bf271c8730c1ed5f20989eb
|
|
| MD5 |
166a0ff07ca4186785e3f667a7592fed
|
|
| BLAKE2b-256 |
00bfd174eb1dadf5a776d584ff32da8476ced93ffb8501026ca955303e943377
|
File details
Details for the file topsis_aastha_102313059-1.0.1-py3-none-any.whl.
File metadata
- Download URL: topsis_aastha_102313059-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8368ec31712ad5f75548414e24887fc89ff6fe373e03e022df36457f4f788ba1
|
|
| MD5 |
81075d41fc83e45a9da270f15b7e6f48
|
|
| BLAKE2b-256 |
52f95288ea2ed61899a3fa18ae4cc2589e13d7a43df4708c8be1645b17f87df8
|