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 matrixWeights: 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file topsis_shivansh_102203508-1.0.1.tar.gz.
File metadata
- Download URL: topsis_shivansh_102203508-1.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fefdbaefbef5689b70efa6335bb46719b0e08b87ff133ab7a53b8c5e6510cf5
|
|
| MD5 |
dcfcafbb16ce0a4fcf1738e9596cec40
|
|
| BLAKE2b-256 |
0ef82237ab69ea535ed0ed6fca465d322bbeaf788cf0b782f34f0ab94dbc2a28
|
File details
Details for the file topsis_Shivansh_102203508-1.0.1-py3-none-any.whl.
File metadata
- Download URL: topsis_Shivansh_102203508-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c53145b436e2175b7d0c177e845ae76475f4e98905ed98a07a0e3fe6b535d680
|
|
| MD5 |
e1ef7bd93c591d6269d3cc26dd2a76a8
|
|
| BLAKE2b-256 |
f71efb5878e8a451c09d2ace8219be53233cb305e417897d94313e5bd3281a80
|