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

Swastikswastik_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.2.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.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for topsis_swastik_102316020-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ead57411acae3382857b3979c442f923c225c93d9f119836754298e1dded0f88
MD5 7a5596bae400e2c005c5d3360146ef8b
BLAKE2b-256 0bc7080310a8e003f505248e56659d9ad5a8396458a886ce4dd6ba89629281e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_swastik_102316020-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 290983e6907f98d7a666be3cf652c2394d1c41e42f77ca9c2112ed11bd66998b
MD5 1a42937c0f35340ef751317a12ee3125
BLAKE2b-256 8863879bf38cd5e7de4bca7d939988c82d218e722945932d74129efe5eb12db0

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