Skip to main content

A Python package for performing TOPSIS analysis.

Project description

TOPSIS-Python

A Python package for implementing the Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS) method.

Description

TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a multi-criteria decision analysis method. This implementation helps decision makers to find the best alternative from a finite set of alternatives based on multiple criteria.

The package provides functionality to:

  • Normalize decision matrices
  • Apply user-defined weights to criteria
  • Handle both positive and negative impact criteria
  • Calculate relative closeness to ideal solutions
  • Rank alternatives based on TOPSIS scores

Installation

You can install the package via pip:

pip install topsis-python

Usage

Command Line Interface

python topsis.py    

Parameters:

  • InputDataFile: Excel file (.xlsx) containing the decision matrix
  • Weights: Comma-separated weights for each criterion (e.g., "0.25,0.25,0.25,0.25")
  • Impacts: Comma-separated impacts for each criterion ('+' for positive, '-' for negative) (e.g., "+,+,-,+")
  • ResultFileName: Output Excel file name where results will be saved

Example:

python topsis.py input.xlsx "0.25,0.25,0.25,0.25" "+,+,-,+" result.xlsx

Input File Format

Your input Excel file should be structured as follows:

  • First column: Alternative names/identifiers
  • Subsequent columns: Criteria values
  • First row: Header with criteria names

Example:

Model   Price   Storage   Camera   Battery
A1      800     128      12       4000
A2      900     256      16       4500
A3      1000    512      20       5000

Output

The program will generate an Excel file containing:

  • All original columns
  • Additional column 'Topsis Score'
  • Additional column 'Rank'

Error Handling

The package handles various errors including:

  • Incorrect number of command-line arguments
  • Invalid input file format
  • Mismatched weights or impacts
  • File I/O errors

Dependencies

  • pandas
  • sys

License

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

Author

Shivansh Gupta

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Sample Code

import pandas as pd
from topsis import topsis

# Read your data
df = pd.read_excel('input.xlsx')

# Define weights and impacts
weights = "0.25,0.25,0.25,0.25"
impacts = "+,+,-,+"

# Calculate TOPSIS
result = topsis(df, weights, impacts)

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

Uploaded Source

Built Distribution

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

topsis_Shivansh_102203508-1.0.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for topsis_shivansh_102203508-1.0.0.tar.gz
Algorithm Hash digest
SHA256 98e6f534b0647a6bfa7b37cb4b5ded54abcc3f1f92a04db0a3b0a7b6fb1aa586
MD5 4d0d7bcc964b5a50d3ff7259edf27294
BLAKE2b-256 7f396166fb9b118129799c0b47caff1a6e1b9310c762a018485051cee9ef1042

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_Shivansh_102203508-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 052d8e6d5e80273132ae83f1d68bff570416b422b605cd4c1ca290ef0aaf4dcc
MD5 53aa60203a914f51afe43e7779588b4d
BLAKE2b-256 f1a01f001af474093b6059ceba71fb1e2766851a37a3481c4d06877b0d2df733

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