Implementation of Topsis
Project description
Project Description
- for: Assignment-1(UCS654)
- Submitted by: Naman Bhargava
- Roll no: 102116058
- Group: 3CS10
TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution)
This Python script is designed to implement the TOPSIS methodology for multi-criteria decision-making. It takes as input a CSV file that includes a decision matrix, user-defined weights, and impact specifications. The script then calculates TOPSIS scores and produces a ranked outcome, offering insights into the decision-making process.
Installation
pip install Topsis-Naman-102103568
Usage
from Topsis_Naman_102116058.topsis import topsis
input="data.csv"
weights="1,1,1,2,1"
impacts="+,+,-,+,-"
result="result.csv"
topsis(input, weights, impacts, result)
OR
You can use this package via command line as:
python -m Topsis_Naman_102116058.topsis [Input as .csv] [Weights as a string] [Impacts as a string] [Result as .csv]
Input: Path to the CSV file containing the input data.Weights: Comma-separated weights for each criterion.Impacts: Comma-separated impact direction for each criterion (+for maximization,-for minimization).Result: Name of the file to save the TOPSIS results.
Requirements
- Python 3
- pandas
- numpy
Input File Format
The input data should be in a CSV format with the following structure:
| Fund Name | P1 | P2 | P3 | P4 | P5 |
|---|---|---|---|---|---|
| M1 | 0.62 | 0.38 | 6.7 | 58.7 | 16.60 |
| M2 | 0.93 | 0.86 | 5.5 | 47.9 | 13.80 |
| M3 | 0.62 | 0.38 | 3.2 | 65.9 | 17.53 |
| M4 | 0.76 | 0.58 | 3.4 | 38.4 | 10.79 |
| M5 | 0.74 | 0.55 | 3.1 | 56.4 | 15.20 |
| M6 | 0.80 | 0.64 | 4.2 | 41.8 | 11.86 |
| M7 | 0.95 | 0.90 | 4.1 | 50.3 | 14.06 |
| M8 | 0.82 | 0.67 | 3.7 | 37.6 | 10.70 |
Output
The script generates a CSV file containing the TOPSIS score and rank for each object:
| Fund Name | P1 | P2 | P3 | P4 | P5 | Topsis Score | Rank |
|---|---|---|---|---|---|---|---|
| M1 | 0.62 | 0.38 | 6.7 | 58.7 | 16.6 | 0.3876 | 8.0 |
| M2 | 0.93 | 0.86 | 5.5 | 47.9 | 13.8 | 0.5213 | 4.0 |
| M3 | 0.62 | 0.38 | 3.2 | 65.9 | 17.53 | 0.5715 | 3.0 |
| M4 | 0.76 | 0.58 | 3.4 | 38.4 | 10.79 | 0.4401 | 7.0 |
| M5 | 0.74 | 0.55 | 3.1 | 56.4 | 15.2 | 0.5977 | 2.0 |
| M6 | 0.8 | 0.64 | 4.2 | 41.8 | 11.86 | 0.4403 | 6.0 |
| M7 | 0.95 | 0.9 | 4.1 | 50.3 | 14.06 | 0.6352 | 1.0 |
| M8 | 0.82 | 0.67 | 3.7 | 37.6 | 10.7 | 0.4517 | 5.0 |
Error Handling
- Display an error message if the input file is not found.
- Raise a ValueError if the number of weights, impacts, or columns in the decision matrix is incorrect.
- Raise a ValueError if the columns from the 2nd to the last do not contain numeric values.
- Display any unexpected errors that occur during execution.
LICENSE
(c) 2024 Naman Bhargava
This project is licensed under the MIT License.
Project details
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-Naman-102116058-1.0.5.tar.gz.
File metadata
- Download URL: Topsis-Naman-102116058-1.0.5.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1cefd5d2e8b527d868044d69e0fef00702273f07f4d493ce10cceaeb4d08d8d
|
|
| MD5 |
9aad3b27ef38d5b07fa4707ba4d12c6e
|
|
| BLAKE2b-256 |
2819e27fc8bac28afbc62aff329d97b99e181b86c21b19f622a8ac2efafc0882
|
File details
Details for the file Topsis_Naman_102116058-1.0.5-py3-none-any.whl.
File metadata
- Download URL: Topsis_Naman_102116058-1.0.5-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a17e0b8fffcaa2c9bb3e8def29e0626bb731b6b3a7fe753516aa1a03212aa8a
|
|
| MD5 |
1cf057f8001cd0aa83d737cbf63343d8
|
|
| BLAKE2b-256 |
8bb18dcfa32afb534c3cac3e82ab15e325e2b142359401711c269904d9cc83ab
|