Skip to main content

A Python package to implement TOPSIS

Project description

TOPSIS-Python

PyPI version

TOPSIS-Python is a Python package for performing the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) evaluation method, a popular multi-criteria decision-making (MCDM) technique. This package simplifies the process of ranking alternatives based on multiple criteria by identifying the option closest to the ideal solution and farthest from the nadir solution.


Installation

You can install the package directly from PyPI using pip:

pip install Topsis-SaiVarsha-102217040

Usage

To use the package, you need a dataset containing alternatives (rows) and their criteria (columns), along with the weights and beneficial/non-beneficial indicators for the criteria.

Command-Line Interface

After installation, the package provides a CLI for quick use:

topsis --input input_file.csv --weights 1,2,3,4 --impacts +,+,-,+ --output output_file.csv

Python API

You can also use the package programmatically:

from topsis import topsis_evaluate

# Example data
data = [
    [250, 16, 12, 5],
    [200, 16, 8, 3],
    [300, 32, 16, 4],
    [275, 32, 8, 4],
    [225, 16, 16, 2]
]
weights = [0.25, 0.25, 0.25, 0.25]
impacts = ['+', '+', '-', '+']

# Perform TOPSIS
rankings = topsis_evaluate(data, weights, impacts)
print(rankings)

Example

Input File

The input file should be a CSV file containing the following structure:

Fund Name P1 P2 P3 P4 P5
M1 0.84 0.71 6.7 42.1 12.59
M2 0.91 0.83 7 31.7 10.11
M3 0.79 0.62 4.8 46.7 13.23
M4 0.78 0.61 6.4 42.4 12.55
M5 0.94 0.88 3.6 62.2 16.91
M6 0.88 0.77 6.5 51.5 14.91
M7 0.66 0.44 5.3 48.9 13.83
M8 0.93 0.86 3.4 37 10.55

Python API Example

from topsis import topsis_evaluate

# Example dataset
data = [
    [0.84, 0.71, 6.7, 42.1, 12.59],
    [0.91, 0.83, 7, 31.7, 10.11],
    [0.79, 0.62, 4.8, 46.7, 13.23],
    [0.78, 0.61, 6.4, 42.4, 12.55],
    [0.94, 0.88, 3.6, 62.2, 16.91],
    [0.88, 0.77, 6.5, 51.5, 14.91],
    [0.66, 0.44, 5.3, 48.9, 13.83],
    [0.93, 0.86, 3.4, 37, 10.55]
]
weights = [0.25, 0.25, 0.25, 0.25, 0.25]
impacts = ['+', '+', '-', '+', '+']

# Perform TOPSIS
rankings = topsis_evaluate(data, weights, impacts)
print("Rankings:", rankings)

Output File

The output file will append two columns to the original dataset:

  • Performance Score
  • Rank
Fund Name P1 P2 P3 P4 P5 Performance Score Rank
M1 0.84 0.71 6.7 42.1 12.59 0.5346 3
M2 0.91 0.83 7 31.7 10.11 0.3084 5
M3 0.79 0.62 4.8 46.7 13.23 0.6912 1
M4 0.78 0.61 6.4 42.4 12.55 0.5346 2
M5 0.94 0.88 3.6 62.2 16.91 0.4038 4
M6 0.88 0.77 6.5 51.5 14.91 0.4912 6
M7 0.66 0.44 5.3 48.9 13.83 0.4238 7
M8 0.93 0.86 3.4 37 10.55 0.3756 8

Input Format

  • CSV File:
    • First row: Criteria names.
    • First column: Alternative names.
    • Remaining cells: Criteria values for each alternative.
  • Weights:
    • A list of non-negative values representing the importance of each criterion.
  • Impacts:
    • A list of + or - for each criterion indicating whether it is beneficial or non-beneficial.

Output Format

The output is a ranked list of alternatives based on their closeness to the ideal solution. The results include:

  1. Performance Score: Closeness of each alternative to the ideal solution.
  2. Rank: Rank of each alternative based on the performance score.

License

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-SaiVarsha-102217040-1.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

Topsis_SaiVarsha_102217040-1.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file Topsis-SaiVarsha-102217040-1.0.1.tar.gz.

File metadata

File hashes

Hashes for Topsis-SaiVarsha-102217040-1.0.1.tar.gz
Algorithm Hash digest
SHA256 05b13b089c7226e353362a63abef653cd128eeff064074f8d5f14952f8489e41
MD5 bff0a3399297d50334ea30e044f75650
BLAKE2b-256 8e4a882a3ba90bb8420d8abf7aca0b30463237b9eb83beb7ca777d0557795f4d

See more details on using hashes here.

File details

Details for the file Topsis_SaiVarsha_102217040-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for Topsis_SaiVarsha_102217040-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 172a7673624cecc0d42a27630eeed20be5523a35ea24f36bcd4de3210b1874e7
MD5 0e52de6fcc33d5818d7789c2be03a45f
BLAKE2b-256 8e6be73d9a28ed74c0aac0292095825316418814b2eda360533675d2ffb62efa

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