Skip to main content

TOPSIS Method for Multi-Criteria Decision Making

Project description

Topsis-Swastik-102316020

PyPI version Python License: MIT

TOPSIS — Technique for Order of Preference by Similarity to Ideal Solution
A Multi-Criteria Decision Making (MCDM) method for ranking alternatives.


Installation

pip install Topsis-swastik-102316020

Command Line Usage

topsis <InputFile> <Weights> <Impacts> <OutputFile>

Example

topsis data.csv "1,1,1,2" "+,+,-,+" result.csv

Python API Usage

from topsis_pkg import run_topsis

run_topsis(
    input_file  = "data.csv",
    weights     = "1,1,1,2",
    impacts     = "+,+,-,+",
    output_file = "result.csv"
)

Input File Format

Your CSV must have:

  • Column 1: Alternative names (text)
  • Columns 2 to last: Numeric criteria values

Example data.csv

Fund Return Risk Expense Liquidity
M1 0.94 0.88 6.3 40.0
M2 0.76 0.58 7.0 45.2
M3 0.93 0.86 3.4 60.6

Parameters

Weights

Comma-separated positive numbers — one per criterion column.
"1,1,1,2" means the 4th criterion is twice as important.

Impacts

Comma-separated + or - — one per criterion column.

Symbol Meaning Example
+ Higher value is better (benefit) Return, Score, Quality
- Lower value is better (cost) Expense, Risk, Price

Output

The result CSV contains all original columns plus two new ones:

Column Description
Topsis Score Score from 0 to 1. Higher = closer to ideal best
Rank 1 = best alternative

Example Output

Fund Return Risk Expense Liquidity Topsis Score Rank
M1 0.94 0.88 6.3 40.0 0.7542 1
M3 0.93 0.86 3.4 60.6 0.6218 2
M2 0.76 0.58 7.0 45.2 0.3782 3

Validations

The package checks for:

  • Correct number of command-line parameters
  • File existence (FileNotFoundError with clear message)
  • Minimum 3 columns in input file
  • Numeric values in criteria columns
  • Matching count of weights, impacts, and columns
  • Valid impact values (+ or - only)
  • Comma-separated format for weights and impacts

Algorithm Steps

  1. Normalize the decision matrix (Euclidean norm)
  2. Weight the normalized matrix
  3. Find Ideal Best (V⁺) and Ideal Worst (V⁻)
  4. Calculate separation distances (d⁺ and d⁻)
  5. Compute performance score: P = d⁻ / (d⁺ + d⁻)
  6. Rank by descending score

License

MIT License — see LICENSE


Author

Your Nameswastik_be23@thapar.edu
GitHub · PyPI

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_swastik_102316020-1.0.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

topsis_swastik_102316020-1.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for topsis_swastik_102316020-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d2d9e02671350afaf123a312181dbbcf0f616e0a0d707e5a9ff37db8bdba226b
MD5 803df2aee3f3112a29d6964c66384bd0
BLAKE2b-256 cfe52314dd873b5ca44764722c899cc3b83a872f991bbd31f2fc7f51c0ee3b52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_swastik_102316020-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca8692863c634653dab73aeedd2348852c5946fb9752d6c9ede56e532d4bf355
MD5 4e72e102e2a37cf9eb5faacddf33991f
BLAKE2b-256 f82c7251674a5639ac15d00219ffe37ce63d2c9eecdf0452dc3f22e4be6dc1ef

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