Skip to main content

TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a multi-criteria decision-making method that ranks alternatives based on their closeness to the ideal solution.

Project description

TOPSIS Python Package

Overview

TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a widely used multi-criteria decision analysis (MCDA) method. It helps in ranking and selecting alternatives based on a set of criteria, where each criterion may have varying importance (weight) and impact (positive or negative).

This package implements the TOPSIS method, which can be used to rank options based on input data, weights, and impacts for each criterion. The results include a ranking, the distance to the ideal best and worst solutions, and the TOPSIS score for each option.

Features

  • Ranking: Ranks options based on a set of criteria.
  • Flexible Inputs: Allows users to specify weights and impacts for each criterion.
  • Ideal Solution Calculation: Computes the distance from both the ideal best and worst solutions.
  • CSV Input and Output: Accepts CSV files for input and generates CSV files for results.

Installation

To install the topsis package, run the following command in your terminal:

pip install Topsis-Gautam-102203061

Usage

Command-Line Usage

After installing the package, you can run the TOPSIS method from the command line using the following syntax:

python -m topsis.topsis input_data.csv "1,2,1,2,1" "+,+,-,-,+" output.csv

Parameters

The command-line tool accepts the following parameters:

  • input_data.csv (Required):

    • Path to the input CSV file containing the data.
    • The first column of the CSV file should represent the options (e.g., Option1, Option2, ...).
    • The remaining columns should contain the criteria values for each option.
  • "1,1,2,2,1" (Required):

    • A comma-separated string representing the weights for each criterion.
    • Each number corresponds to the importance of a criterion. The higher the number, the more important the criterion is.
  • "+,+,-,-,-" (Required):

    • A comma-separated string representing the impacts for each criterion.
    • The impacts can be either:
      • + for positive impact: A higher value for the criterion is better.
      • - for negative impact: A lower value for the criterion is better.
  • result.csv (Required):

    • Path to the output CSV file where the results will be saved.
    • The output file will contain the following columns:
      • Option: The option name.
      • Distance from Ideal Best: The Euclidean distance of each option from the best possible solution.
      • Distance from Ideal Worst: The Euclidean distance of each option from the worst possible solution.
      • TOPSIS Score: A score that indicates how close each option is to the ideal solution.
      • Rank: The rank of each option based on its TOPSIS score (1 being the best).

Example

Input CSV: input_data.csv

Option,Criterion1,Criterion2,Criterion3,Criterion4,Criterion5
Option1,7,9,6,8,7
Option2,8,7,9,7,8
Option3,6,5,8,6,5

Syntax

To use the TOPSIS method, run the following command in the terminal:

python -m topsis.topsis <input_data.csv> <weights> <impacts> <result.csv>

Output CSV: result.csv

The output of the TOPSIS method is saved in a CSV file named result.csv with the following structure:

Option,Distance from Ideal Best,Distance from Ideal Worst,TOPSIS Score,Rank
Option1,2.5,5.0,0.6667,1
Option2,3.0,4.5,0.6,2
Option3,3.5,3.0,0.4615,3

Understanding the Output

  • Distance from Ideal Best:

    • Euclidean distance of each option from the best possible solution. The ideal best solution is the one that has the maximum value in all positive impact criteria and the minimum in all negative impact criteria.
  • Distance from Ideal Worst:

    • Euclidean distance of each option from the worst possible solution. The ideal worst solution is the one that has the minimum value in all positive impact criteria and the maximum in all negative impact criteria.
  • TOPSIS Score:

    • The score that indicates how close each option is to the ideal solution. A higher score means the option is closer to the ideal solution.
  • Rank:

    • The ranking of each option based on its TOPSIS score (1 being the best).

License

© 2025 Gautam

This repository is licensed under the MIT license. See LICENSE for details.

Additional Notes

  • The package requires Python 3.6 or higher.
  • Ensure the input data is clean and contains only numerical values for the criteria columns.
  • The package works with CSV files where the first column contains options (e.g., Option1, Option2, etc.) and the remaining columns contain numerical values representing the criteria.

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_gautam_102203061-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

Topsis_Gautam_102203061-1.0.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file topsis_gautam_102203061-1.0.0.tar.gz.

File metadata

  • Download URL: topsis_gautam_102203061-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for topsis_gautam_102203061-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7c7d1db67153baeba630bdcf118cb70b3e60940c6a3f8d8f9b6dee91afd7f363
MD5 cd5a6013ad49459c4af76599824d89c3
BLAKE2b-256 7ef2202ebe395195fef61de82a4d1fffefc3190ba88624bf720914c739beeacb

See more details on using hashes here.

File details

Details for the file Topsis_Gautam_102203061-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for Topsis_Gautam_102203061-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2126fdc255947f16c5f5ab5cd5759f6cf47594704a969fc0911d168f39f8d04
MD5 97e298df1dfacd9f33b0043a5abcb77f
BLAKE2b-256 10463998e05ab5e29e1ee0405f6b129ab16498ce106cf1ad03473cdc90aa3722

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