Skip to main content

A Python package for TOPSIS decision making

Project description

TOPSIS-Vansh-102353012

A Python library for solving Multiple Criteria Decision Making (MCDM) problems using the Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS).

Project Description

This package implements TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution), a multi-criteria decision analysis method. TOPSIS is based on the concept that the chosen alternative should have the shortest geometric distance from the positive ideal solution and the longest geometric distance from the negative ideal solution.

Installation

Use the package manager pip to install the package:

pip install topsis-vansh-102353012

Usage

Enter CSV filename followed by .csv extension, then enter the weights vector with vector values separated by commas, followed by the impacts vector with comma separated signs (+,-).

Method 1: With quotes

topsis sample.csv "1,1,1,1" "+,-,+,+" output.csv

Method 2: Without quotes

topsis sample.csv 1,1,1,1 +,-,+,+ output.csv

Note: The second representation does not provide for inadvertent spaces between vector values. So, if the input string contains spaces, make sure to enclose it between double quotes ("").

To view usage help, use:

topsis -h

Example

sample.csv

A CSV file showing data for different mobile handsets having varying features:

Model Storage space(in gb) Camera(in MP) Price(in $) Looks(out of 5)
M1 16 12 250 5
M2 16 8 200 3
M3 32 16 300 4
M4 32 8 275 4
M5 16 16 225 2

Input

topsis sample.csv "0.25,0.25,0.25,0.25" "+,+,-,+" output.csv

Where:

  • weights vector = [0.25, 0.25, 0.25, 0.25]
  • impacts vector = [+, +, -, +]

Output

TOPSIS RESULTS
------------------------------
Model  P-Score  Rank
   M3  0.691632    1
   M4  0.534737    2
   M1  0.534277    3
   M5  0.401046    4
   M2  0.308368    5

The results show the TOPSIS score (P-Score) and rank for each alternative, where rank 1 indicates the best option.

Other Notes

  • The first column and first row are removed by the library before processing, in attempt to remove indices and headers. So make sure the CSV follows the format as shown in sample.csv
  • Make sure the CSV does not contain categorical values
  • Ensure the number of weights and impacts matches the number of criteria (columns)
  • Impacts must be either '+' (beneficial) or '-' (non-beneficial)

Input File Format Requirements

  1. The input file must be a CSV with the first column as object/alternative names
  2. From the 2nd column onwards, there must be numeric values only
  3. The number of weights, impacts, and columns (from 2nd column) must be the same
  4. Impacts must be either +ve ('+') or -ve ('-')
  5. Weights must be numeric and greater than 0

Algorithm

TOPSIS follows these steps:

  1. Normalize the decision matrix
  2. Calculate weighted normalized decision matrix
  3. Determine ideal best and ideal worst solutions
  4. Calculate Euclidean distances from ideal best and ideal worst
  5. Calculate performance score and rank alternatives

Features

  • ✅ Easy to use command-line interface
  • ✅ Handles multiple criteria decision making
  • ✅ Automatic validation of inputs
  • ✅ Generates ranked results with TOPSIS scores
  • ✅ Exports results to CSV format
  • ✅ Comprehensive error handling

Requirements

  • Python >=3.6
  • pandas >=1.0.0
  • numpy >=1.18.0

Author

Vansh Garg
Roll No: 102353012
Email: vanshgarg1635@gmail.com

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Keywords

  • TOPSIS
  • MCDM
  • Multi-Criteria Decision Making
  • Decision Analysis
  • Optimization
  • Python
  • Data Science

Version History

  • 1.0.0 (Initial Release)
    • Basic TOPSIS implementation
    • Command-line interface
    • CSV input/output support
    • Input validation
    • Error handling

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_vansh_102353012-1.0.1.tar.gz (4.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_vansh_102353012-1.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file topsis_vansh_102353012-1.0.1.tar.gz.

File metadata

  • Download URL: topsis_vansh_102353012-1.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for topsis_vansh_102353012-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f3c0decfd0bb077faecc527c47ef675a3a66bfce848f66dbc2b521f811e63da0
MD5 16873a6ceea6b526c59654d10577fb2f
BLAKE2b-256 9445b752469bd04bc84f95ce1433f1c75423b70a5d7a4a7a81ee0e7458d53e61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_vansh_102353012-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c07a16247cac4254e4369159a1f33211f99c13eac5da52e0033a81f29bd3465
MD5 4b822fda3c04af6075d8f4c29a806df5
BLAKE2b-256 ace769a776de298f9742dd29fd4e03578640116c62dfde2eff693facb784cf24

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