Skip to main content

TOPSIS decision method Python package

Project description

TOPSIS Implementation (Sachin Goyal)

Simple TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) implementation in Python.

Project structure

  • data.csv (example input)
  • setup.py (packaging / install - optional)
  • topsis/ (package)
    • init.py
    • topsis.py (main implementation and CLI)

Summary

  • Reads a CSV where the first column is an identifier (name) and the remaining columns are numeric criteria.
  • Computes TOPSIS scores and ranks using provided weights and impacts.
  • Writes an output CSV that includes the original data plus Topsis Score and Rank columns.

Prerequisites

  • Python 3.6+
  • pandas and numpy

Quick install (no virtualenv):

Open a terminal and run:

python -m pip install pandas numpy

Or create a virtual environment first, then install the same packages.

Usage

There are two simple ways to run the script.

  1. Run as a module (from project root):

    python -m topsis.topsis "" ""

  2. Run the script file directly:

    python topsis\topsis.py "" ""

Arguments

  • : path to the input CSV file.
  • : comma-separated numeric weights for each criterion (e.g. "1,1,1,1").
  • : comma-separated + or - for each criterion (e.g. "+,+,-, +").
  • : path for the output CSV.

Input CSV format

  • Must have at least 3 columns (first column: identifier; at least two criteria columns).

  • All columns from the 2nd to last must contain numeric values.

  • Example:

    Name,Cost,Performance,Reliability A,250,8,9 B,200,7,8

Example

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

This will produce result.csv with two extra columns:

  • Topsis Score (higher is better)
  • Rank (1 = best)

Common errors and messages

  • "Input file not found": the specified input file path doesn't exist.
  • "Unable to read input file": input file not a valid CSV.
  • "Input file must contain at least 3 columns": CSV missing required columns.
  • "All columns from 2nd to last must contain numeric values": non-numeric values in criteria columns.
  • "Number of weights must be equal to number of criteria": mismatch between provided weights and criteria count.
  • "Number of impacts must be equal to number of criteria": mismatch between provided impacts and criteria count.
  • "Impacts must be either + or -": impacts should be "+" or "-" only.
  • "Weights must be numeric": weights should be numbers.

Notes

  • Weights are normalized implicitly by the algorithm's normalization step.
  • The implementation uses Euclidean normalization.

Author

  • Sachin Goyal (student project)

License

  • Use or adapt as needed for learning or coursework.

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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for topsis_sachingoyal_102303557-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3d6c99a768772923c8f0016515b4841c2b2e3ebea4579bedf0320d794ee4a6ff
MD5 06e982ba7427287de7cc77e233ac4925
BLAKE2b-256 86ed5b8ea455fcd82aad657ce0116b2992b7c4bfcd9d29cec0d2e28c124b18b6

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