Skip to main content

A Python package for TOPSIS multi-criteria decision making method

Project description

TOPSIS — Khushi (102303610)

Topsis-Khushi-102303610 is a Python library for solving Multiple Criteria Decision Making (MCDM) problems using the Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS).


What is TOPSIS?

TOPSIS is a decision-making method used when you need to choose the best option from several alternatives based on multiple criteria.

Core Concept

The best alternative should have:

  • The shortest distance from the Positive Ideal Solution (best possible values)
  • The longest distance from the Negative Ideal Solution (worst possible values)

Simple Example

Imagine choosing a mutual fund based on:

  • P1 (higher is better) ✓
  • P2 (higher is better) ✓
  • P3 (lower is better) ✗
  • P4 (higher is better) ✓

TOPSIS calculates a score for each fund and ranks them to help you pick the best one!


Features

  • ✅ Simple command-line interface
  • ✅ Handles any number of alternatives and criteria
  • ✅ Automatic normalization of data
  • ✅ Supports both beneficial (+) and non-beneficial (-) criteria
  • ✅ Generates ranked output with TOPSIS scores
  • ✅ Easy to install and use

Installation

Install the package using pip:

pip install Topsis-Khushi-102303610

Usage

Run TOPSIS from the command line:

topsis <InputFile.csv> <Weights> <Impacts> <OutputFile.csv>

Method 1: With Quotes (Recommended)

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

Method 2: Without Quotes

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

Important:
Method 2 does not allow spaces. Always use quotes if there are spaces in your input.

Get Help

topsis -h

Input File Format

The input must be a CSV file with the following structure:

Requirements

  • First column: Names or IDs of alternatives (text)
  • Remaining columns: Numerical criteria values only
  • First row: Column headers

Example: data.csv

Fund Name,P1,P2,P3,P4
M1,0.67,0.45,6.5,42.6
M2,0.6,0.36,3.6,53.3
M3,0.82,0.67,3.8,63.1
M4,0.6,0.36,3.5,69.2

Where:

  • Fund Name = Name of the mutual fund
  • P1, P2, P3, P4 = Different performance criteria to evaluate

Example

Input File: data.csv

Fund Name,P1,P2,P3,P4
M1,0.67,0.45,6.5,42.6
M2,0.6,0.36,3.6,53.3
M3,0.82,0.67,3.8,63.1
M4,0.6,0.36,3.5,69.2

Command

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

Parameters Explained

Parameter Value Meaning
Weights 0.25,0.25,0.25,0.25 All criteria have equal importance (25% each)
Impacts +,+,-,+ P1 ✓, P2 ✓, P3 ✗, P4 ✓

Impacts:

  • + means higher is better (beneficial)
  • - means lower is better (non-beneficial)

Output: output.csv

Fund Name,P1,P2,P3,P4,Topsis Score,Rank
M1,0.67,0.45,6.5,42.6,0.448532,3
M2,0.6,0.36,3.6,53.3,0.532891,2
M3,0.82,0.67,3.8,63.1,0.691876,1
M4,0.6,0.36,3.5,69.2,0.589247,2

Result: Fund M3 is ranked 1st (best choice) with the highest TOPSIS Score.


Input Validation Rules

The package validates your input to ensure correctness:

Rule Description
✓ File format Must be a .csv file
✓ Minimum alternatives At least 2 rows of data
✓ Minimum criteria At least 2 criteria columns
✓ Numeric values All criteria values must be numbers
✓ Matching counts Number of weights = Number of impacts = Number of criteria
✓ Valid impacts Only + or - allowed
✓ Positive weights All weights must be > 0

How TOPSIS Works (Algorithm)

  1. Normalize the decision matrix
  2. Calculate the weighted normalized matrix
  3. Determine the Ideal Best (positive ideal solution)
  4. Determine the Ideal Worst (negative ideal solution)
  5. Calculate Euclidean distances from ideal best and worst
  6. Compute TOPSIS performance score for each alternative
  7. Rank alternatives (1 = best)

Error Handling

Common errors and solutions:

Error Cause Solution
File not found Wrong file path Check the file name and path
Wrong number of parameters Mismatch in counts Ensure weights, impacts, and criteria match
Non-numeric values Text in criteria columns All criteria must be numbers (except first column)
Invalid impact Wrong symbol used Use only + or -
Invalid weights Zero or negative weight All weights must be positive numbers

Package Information

Author: Khushi
Roll Number: 102303610
Institution: Thapar Institute of Engineering and Technology
Version: 1.0.0
License: MIT


Keywords

TOPSIS, MCDM, Multi-Criteria Decision Making, Decision Analysis, Optimization, Python, Data Science, Operations Research


For any issues or questions, please refer to the package documentation or contact the author.

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_khushi_102303610-1.0.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

topsis_khushi_102303610-1.0.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: topsis_khushi_102303610-1.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for topsis_khushi_102303610-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e7d6e37f747737dca87f7d558b3742be73944e1f2349e8086ec47afc03a7165d
MD5 d179770c14e67c76e2218a73bde954ab
BLAKE2b-256 2d883448f1c8cba08026642754e83d1c8ca14a7b2fa9f68135120f84e36957cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_khushi_102303610-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 134a365ffa3c0503b4612c740dac716600a60eaeca1184afd585366c720062a0
MD5 e83cc6f8399f5bc463407d5de8e97b2b
BLAKE2b-256 d03cd5836421e33a8016530e3eba57f0fde6b013ceafd2434afe2c2152aef33f

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