Skip to main content

TOPSIS Method for Multi-Criteria Decision Making

Project description

Topsis-Shubham-102316044

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-shubham-102316044

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

Shubhamshubham_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_shubham_102316044-1.0.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

topsis_shubham_102316044-1.0.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file topsis_shubham_102316044-1.0.2.tar.gz.

File metadata

  • Download URL: topsis_shubham_102316044-1.0.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for topsis_shubham_102316044-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f151aa259937522604e334cf3759b9742bcfefcf4d78df206810db9977b9fc4c
MD5 c06dded29b72b98726e6634c8e54af6c
BLAKE2b-256 3b8f2d33030d7823faebdd4d3a4bdb6a8f65411ab733a418f20541ce86c8eb1e

See more details on using hashes here.

File details

Details for the file topsis_shubham_102316044-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for topsis_shubham_102316044-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8e5219ede4f6665052b22dd445f169984c78e5dd2f72a24be41f68f11b9e6f6d
MD5 77f0ad544f7cf37ea6089aa54f23fd93
BLAKE2b-256 5520ff3dac94822c24004ebb7d1ca43fa2defb057ac96079fbccdfff364ad528

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