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 implements the TOPSIS method for multi-criteria decision-making. It takes a CSV file containing a decision matrix, weights, and impacts as input, and produces a ranked result based on the TOPSIS score.

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

Topsis-Naman-102116058-1.0.4.tar.gz (3.6 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.4-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: Topsis-Naman-102116058-1.0.4.tar.gz
  • Upload date:
  • Size: 3.6 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.4.tar.gz
Algorithm Hash digest
SHA256 6047a926be431488c9529bd007dad786e7302886e58958e6277f339901273ef2
MD5 cf59b76f9cf8f482d26a4a02ec61ad8d
BLAKE2b-256 93f995396804445385180ed4d9c76b776f57e37706b4f2e000d9e3b088b6a223

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Topsis_Naman_102116058-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 530038aac8e67936f66ca69db58993595168cf1f69ec41f2acde12a2dab401e3
MD5 daa05dcd0fa3c3dc4869bcce4fb20d1e
BLAKE2b-256 d9f43e1abcd7b5d1c5c64d3717fcd9a0aebe2c17aecce7cebeac018f30d2a00a

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