Skip to main content

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].

Metadata

Release files for 102203148-topsis 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for 102203148-topsis 1.0.0
File Size Uploaded Provenance
102203148_topsis-1.0.0.tar.gz 3.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for 102203148-topsis 1.0.0
File Interpreter ABI Platform
102203148_topsis-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / 102203148_topsis-1.0.0.tar.gz

Download URL 102203148_topsis-1.0.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
31ef96d1992068feed8e409ba3eb7d67df2e516ccf8dbe3433da955153da713e
BLAKE2b-256 checksum
How to use checksums
140f82de017beb9411e699da72e0674b7b7caeeefe1a0442b10d474cd1c19f27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.5

Release files / 102203148_topsis-1.0.0-py3-none-any.whl

Download URL 102203148_topsis-1.0.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ec818ebe1ed501b328ad74df18c4dcbe4466a7ff23b37cecc5ae2eaf15479c9
BLAKE2b-256 checksum
How to use checksums
2ce9bebf1a2dad22c25ca24e5e3bad7a3697bb4676f031ce7192a61a57dcd723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.5

Security for 102203148-topsis 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page