No project description provided
Project description
TOPSIS Analysis Package
A Python package for performing TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) analysis on numerical datasets. This package provides both a command-line interface and a importable module for performing TOPSIS analysis on datasets containing numerical data (int32, int64, float32, float64).
Overview
TOPSIS is a multi-criteria decision analysis method that helps identify the best alternative from a set of options based on multiple criteria. The package normalizes the input data, applies weights to different criteria, and considers whether each criterion should be maximized or minimized.
Installation
pip install topsis-102217132
Usage
As a Module
from topsis_analysis import run
# Perform TOPSIS analysis
result_df = run(
input_df, # pandas DataFrame with numerical values
weights, # List of weights for each criterion
impacts, # List of impacts ('+' or '-') for each criterion
)
Command Line Interface
python -m topsis_analysis <source_csv> <weights> <impacts> <output_csv>
Parameters
For Both Module and CLI:
-
Input Data:
- Must contain only numerical values (int32, int64, float32, float64)
- First column will be used as index
- No missing values allowed
-
Weights:
- Must sum to 1
- Number of weights must match number of columns (excluding index)
- Module: List of float values
- CLI: Comma-separated values (e.g., "0.25,0.25,0.25,0.25")
-
Impacts:
- Use '+' for criteria to be maximized
- Use '-' for criteria to be minimized
- Number of impacts must match number of columns (excluding index)
- Module: List of strings
- CLI: Comma-separated signs (e.g., "-,+,+,+")
CLI Only:
output_csv: Path where the result CSV will be stored
Example Usage
As a Module
import pandas as pd
from topsis_analysis import run
# Read input data
df = pd.read_csv('data.csv')
# Define weights and impacts
weights = [0.25, 0.25, 0.25, 0.25]
impacts = ['-', '+', '+', '+']
# Run TOPSIS analysis
result = run(df, weights, impacts)
# Save results if needed
result.to_csv('output.csv', index=False)
Command Line
python -m topsis-102217132 data.csv 0.25,0.25,0.25,0.25 -,+,+,+ output.csv
Input CSV Format
Model,Price,Storage,Battery,Performance
1,799,256,12,85
2,999,512,10,92
3,699,128,15,78
- Weights not summing to 1
Output Format
Model,Price,Storage,Battery,Performance,TOPSIS Score,Rank
1,799,256,12,85,0.534,2
2,999,512,10,92,0.687,1
3,699,128,15,78,0.423,3
Error Handling
The package provides comprehensive error handling for:
- Invalid number of weights or impacts
- Invalid data types
- Missing values in the dataset
- Invalid file paths (CLI only)
- Non-numeric data in columns
- Invalid impact symbols
Dependencies
- Python 3.7+
- pandas
- numpy
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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-Angad-Singh-102217132-0.0.1.tar.gz.
File metadata
- Download URL: topsis-Angad-Singh-102217132-0.0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a7e661d5c836b07b65d698b36f891605fb76062bfb6ebe60965729ce6bb2026
|
|
| MD5 |
f17faf1898daa77f8678ad29f20696a0
|
|
| BLAKE2b-256 |
fae1a1510cbc45c43be9a7524ec2cff4a592ae6d10b4f9d27a6fcecfe010eeb3
|
File details
Details for the file topsis_Angad_Singh_102217132-0.0.1-py3-none-any.whl.
File metadata
- Download URL: topsis_Angad_Singh_102217132-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf99ce2cc4d8e72c402114d9f2c3d0697d37d52a85fa0e5d47833e85e8e640b9
|
|
| MD5 |
f1903e75a06b6ddc6d91c1587a153b27
|
|
| BLAKE2b-256 |
be9aa74af1cda7653107c246ab3a758bb6b673a23f9064736b31391fdc573d70
|