Skip to main content

A Python package for multi-criteria decision-making using the TOPSIS method.

Project description

TOPSIS Implementation

Overview

This Python package provides a straightforward implementation of the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) method for multi-criteria decision-making. With this tool, you can rank alternatives based on multiple criteria using weights and impacts for each criterion.

Features

  • Easy-to-use command-line interface.
  • Supports customizable weights and impacts for criteria.
  • Outputs a ranked list of alternatives with TOPSIS scores.
  • Handles CSV input and output for seamless integration with data workflows.

Usage

Command-Line Interface

To execute TOPSIS, use the following command:

python topsis.py <input_file> <weights> <impacts> <output_file>

Arguments

  • <input_file>: Path to the CSV file containing the input data. The first column should contain alternative names, and subsequent columns should contain numerical criteria values.
  • <weights>: Comma-separated weights for each criterion (e.g., 1,2,3).
  • <impacts>: Comma-separated impacts for each criterion (+ for benefit criteria, - for cost criteria, e.g., +, -, +).
  • <output_file>: Path to the CSV file where the results will be saved.

Example

Suppose you have the following input file (data.csv):

Alternative Criterion 1 Criterion 2 Criterion 3
A1 250 16 12
A2 200 20 8
A3 300 12 15
A4 275 14 10

To rank the alternatives with weights 1,1,1 and impacts +, +, -, run:

python topsis.py data.csv 1,1,1 +,+,- results.csv

The output (results.csv) will include the TOPSIS scores and ranks:

Alternative Criterion 1 Criterion 2 Criterion 3 Topsis Score Rank
A1 250 16 12 0.6547 2
A2 200 20 8 0.3001 4
A3 300 12 15 0.8234 1
A4 275 14 10 0.4921 3

Input File Requirements

  • The input file must be a CSV with at least three columns.
  • The first column should contain the names of the alternatives.
  • The remaining columns should contain numerical values for criteria.

Output File

The output file will contain the original data along with two additional columns:

  • Topsis Score: The calculated TOPSIS score for each alternative.
  • Rank: The rank of each alternative based on the TOPSIS score (1 = best).

Error Handling

The package validates inputs and raises errors for:

  • Input files with fewer than three columns.
  • Mismatched lengths of weights or impacts compared to the criteria.
  • Invalid impact values (must be + or -).

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

Contact

For questions or feedback, please contact [aryan10767@gmail.com.com].

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

102203148_topsis-1.0.0.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.

102203148_topsis-1.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file 102203148_topsis-1.0.0.tar.gz.

File metadata

  • Download URL: 102203148_topsis-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.5

File hashes

Hashes for 102203148_topsis-1.0.0.tar.gz
Algorithm Hash digest
SHA256 31ef96d1992068feed8e409ba3eb7d67df2e516ccf8dbe3433da955153da713e
MD5 f7b9c6edd83c4586ed30e7404c1807b3
BLAKE2b-256 140f82de017beb9411e699da72e0674b7b7caeeefe1a0442b10d474cd1c19f27

See more details on using hashes here.

File details

Details for the file 102203148_topsis-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for 102203148_topsis-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ec818ebe1ed501b328ad74df18c4dcbe4466a7ff23b37cecc5ae2eaf15479c9
MD5 48260e627587954874f4bd633c61cdff
BLAKE2b-256 2ce9bebf1a2dad22c25ca24e5e3bad7a3697bb4676f031ce7192a61a57dcd723

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