Skip to main content

A Python package to perform TOPSIS analysis for multi-criteria decision making

Project description

TOPSIS Implementation in Python

A simple command-line tool and Python package for performing TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) analysis on multi-criteria decision-making problems.

What is TOPSIS?

TOPSIS is a method used to find the best alternative from a set of options based on multiple criteria. It works by:

  1. Normalizing the decision matrix
  2. Applying weights to criteria
  3. Finding ideal best and worst solutions
  4. Calculating distances from these ideal points
  5. Ranking alternatives based on relative closeness to the ideal best

Installation

You can install this package using pip:

pip install Topsis-Naman-102317144

Usage

Command Line

After installation, you can use the topsis command directly from terminal:

topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>

Example:

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

Python Package

You can also import and use it in your Python code:

from Topsis_Naman_102317144 import run_topsis

# Run TOPSIS analysis
run_topsis('data.csv', '1,1,1,1,1', '+,+,-,+,+', 'result.csv')

Input File Format

The input file should be a CSV or Excel file with:

  • First column: Name/ID of alternatives
  • Remaining columns: Criteria values (numeric only)

Example (data.csv):

Fund Name,P1,P2,P3,P4,P5
M1,0.84,0.71,6.7,42.1,12.59
M2,0.91,0.83,7.0,31.7,10.11
M3,0.79,0.62,4.8,46.7,13.23

Parameters

  • Weights: Comma-separated numbers representing importance of each criterion

    • Example: "1,1,1,2" means 4 criteria with last one having double weight
  • Impacts: Comma-separated + or - signs

    • + means higher value is better (benefit criteria)
    • - means lower value is better (cost criteria)
    • Example: "+,+,-,+,+" means 3rd criterion is cost, others are benefits

Output

The program generates a CSV file with:

  • All original columns
  • Topsis Score: Calculated score for each alternative
  • Rank: Ranking based on TOPSIS score (1 is best)

Error Handling

The program checks for:

  • Correct number of parameters
  • File existence
  • Minimum 3 columns in input
  • Numeric values in criteria columns
  • Matching count of weights, impacts, and criteria
  • Valid impact values (+ or -)

Example

# Install the package
pip install Topsis-Naman-102317144

# Run TOPSIS
topsis input.csv "1,2,1,1" "+,-,+,+" output.csv

Requirements

  • Python 3.6+
  • pandas
  • numpy

License

MIT License - feel free to use this for your projects!

Author

Naman Singh (Roll: 102317144)

Version

1.0.3

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_naman_102317144-1.0.3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

topsis_naman_102317144-1.0.3-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file topsis_naman_102317144-1.0.3.tar.gz.

File metadata

  • Download URL: topsis_naman_102317144-1.0.3.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for topsis_naman_102317144-1.0.3.tar.gz
Algorithm Hash digest
SHA256 af53410022594c8a2ca2fe2d2a5a77decdd715a1eef2d5558348480f1e451441
MD5 e62ca4b1cde8960994bf6f621e279978
BLAKE2b-256 d731e5d858a389abdf94fca51f381dfa55a54b170d83f7368933627e8d476a70

See more details on using hashes here.

File details

Details for the file topsis_naman_102317144-1.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for topsis_naman_102317144-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 21339b366174b826cd2cecc3861f01c701eda09a445e76361164065aa334b5a9
MD5 34ee27e0dfaf75c30e5c5182633d07e1
BLAKE2b-256 969d3964d48c1606b41829400380977078732e5211b15bba55655158d4a45130

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