Skip to main content

TOPSIS Method for Multi-Criteria Decision Making

Project description

Topsis-YourName-YourRollNumber

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-YourName-YourRollNumber

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 Nameyour.email@gmail.com
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.0.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.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for topsis_swastik_102316020-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d69d46b9ab1a3f54e1c629a84c82e76b4be908e4f9a6f80cabb2ef052e3ce77f
MD5 d2b2fdd01f96ad45dd9d8c983ece2c72
BLAKE2b-256 2253927beff36ccfc35a979f4ddabe8ed49010902c531b92594858b30245d0e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_swastik_102316020-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e32773005c7e8d5350e2ec5f7d28517decb668a734cfe9084530a056eee6bc2a
MD5 5f079ae105e78ed3b2818d008f4fd7ec
BLAKE2b-256 0e64d19b0b7cb010ae52d99054ce5bef8a1d7eab46513014e5fee65d1eac9c22

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