Skip to main content

A Python implementation of the TOPSIS decision-making method

Project description

TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution)

TOPSIS is a Python library for implementing the Technique for Order of Preference by Similarity to Ideal Solution, a multi-criteria decision-making method. This library allows users to rank alternatives based on given criteria, weights, and impacts.

Installation

You can install the library via pip:

pip install topsis-Mridul

Usage

Command-line Usage

The library can be used directly from the command line. Here's the general syntax:

python <program.py>

Example

Create an input file, data.csv:

Name,C1,C2,C3,C4 A,250,16,12,5 B,200,32,8,3 C,300,24,10,4 D,275,20,11,4 E,225,28,9,2

Run the command:

python topsis.py data.csv "0.25,0.25,0.25,0.25" "+,+,-,+" result.csv

The output result.csv will contain:

Name,C1,C2,C3,C4,Topsis Score,Rank A,250,16,12,5,0.64,2 B,200,32,8,3,0.43,4 C,300,24,10,4,0.78,1 D,275,20,11,4,0.56,3 E,225,28,9,2,0.36,5

Python Library Usage

Importing the Library

You can also use the library directly in Python:

from topsis import Topsis

Input data

data = "data.csv" weights = [0.25, 0.25, 0.25, 0.25] impacts = ["+", "+", "-", "+"] result_file = "result.csv"

Perform TOPSIS

Topsis(data, weights, impacts, result_file) print(f"Results saved in {result_file}")

Parameters

InputDataFile: A CSV file with the first column as the name of the alternatives and the rest as numeric criteria.

Weights: A comma-separated string of numeric weights (e.g., "0.25,0.25,0.25,0.25").

Impacts: A comma-separated string of impacts for each criterion, either + (positive impact) or - (negative impact).

ResultFileName: The name of the output CSV file where results will be saved.

Features

Validate input file format and values.

Handle missing or invalid values gracefully.

Normalize and weight criteria.

Calculate TOPSIS scores and rankings.

Limitations

All criteria must be numeric.

The number of weights and impacts must match the number of criteria.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Feel free to open issues or create pull requests to improve the library!

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

Uploaded Source

Built Distribution

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

topsis_mridul-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: topsis_mridul-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for topsis_mridul-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e4c2dcccec3239198f50f160c62ba57eb3767739481006f9c3282d9f6a8bf65f
MD5 fb7a1636a67636a1305d05deea2340d6
BLAKE2b-256 bbdccae4b8284f0e8fd300f6ae82c09f2ed8438b90f38bc22923d434069d486f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: topsis_mridul-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for topsis_mridul-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3eb6017e730e725e3939ceb2e2c5f89b8ff43a18645d5c31fe2c1f58661fe464
MD5 e1ef57771bad897261a27b7a079a3a35
BLAKE2b-256 0066b0d11f0f8e121c8d90060b903edef1f14d931841a5d85e9bcf4cffbf3fb2

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