Skip to main content

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-102116058

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

Topsis-Naman-102116058-1.0.6.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Topsis_Naman_102116058-1.0.6-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file Topsis-Naman-102116058-1.0.6.tar.gz.

File metadata

  • Download URL: Topsis-Naman-102116058-1.0.6.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

Hashes for Topsis-Naman-102116058-1.0.6.tar.gz
Algorithm Hash digest
SHA256 0da3235df8f4cfdb04a0b08bfa45f68f0d202974d05f069d5ac4241562883a8d
MD5 37138e38d6cb191410cc644d2382ec6e
BLAKE2b-256 5e52095b2d5e85eecb92b9cd3260de3ca953a9a77b81013e9bff72db76036e68

See more details on using hashes here.

File details

Details for the file Topsis_Naman_102116058-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for Topsis_Naman_102116058-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 07051bb5cd6dd3474b5c62bbaccebc9aa0a20c7e122aafeca98639905c9f3f0e
MD5 8deeef7a3d1d5e0bed126d9b7682deb2
BLAKE2b-256 a4870dfec7f105c7e331df89494c38673e4acf2128747190458c7b0dcba89bb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page