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-Shivansh-102203508

Usage

Command Line Interface

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

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:

topsis 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-Shivansh-102203508 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.1.tar.gz (4.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_Shivansh_102203508-1.0.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for topsis_shivansh_102203508-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4fefdbaefbef5689b70efa6335bb46719b0e08b87ff133ab7a53b8c5e6510cf5
MD5 dcfcafbb16ce0a4fcf1738e9596cec40
BLAKE2b-256 0ef82237ab69ea535ed0ed6fca465d322bbeaf788cf0b782f34f0ab94dbc2a28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_Shivansh_102203508-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c53145b436e2175b7d0c177e845ae76475f4e98905ed98a07a0e3fe6b535d680
MD5 e1ef7bd93c591d6269d3cc26dd2a76a8
BLAKE2b-256 f71efb5878e8a451c09d2ace8219be53233cb305e417897d94313e5bd3281a80

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