A Python package for implementing the TOPSIS decision-making method.
Project description
Topsis-Vansh-102203021
A Python package to implement the TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) method for multi-criteria decision-making problems.
Features
- Rank alternatives based on multiple criteria.
- Handle positive and negative impacts of criteria.
- Simple to use with CSV input/output.
- Fully customizable weights and impacts.
Installation
Install the package directly from PyPI:
pip install Topsis-Vansh-102203021
How to Use
The package can be used through the command line or imported into a Python script.
Command-Line Usage
The basic syntax for using the package via the command line:
python -m topsis <input_file> <weights> <impacts> <output_file>
Parameters:
input_file: CSV file containing the decision matrix.weights: Comma-separated values representing the importance of each criterion (e.g.,1,1,2,3).impacts: Comma-separated values representing the impact of each criterion (+for positive,-for negative).output_file: Name of the CSV file where the results will be saved.
Example:
python -m topsis data.csv "1,1,2,3" "+,+,-,+" result.csv
Input File Format:
The input file must be a CSV file with the following structure:
| Alternatives | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 |
|---|---|---|---|---|
| A1 | 250 | 16 | 12 | 5 |
| A2 | 200 | 18 | 8 | 3 |
| A3 | 300 | 14 | 16 | 7 |
| A4 | 275 | 17 | 10 | 4 |
- The first column contains alternative names (e.g., A1, A2, etc.).
- From the second column onwards, numeric values for each criterion are provided.
Output File Format:
The output file will include the input data along with two additional columns:
| Alternatives | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 | Topsis Score | Rank |
|---|---|---|---|---|---|---|
| A1 | 250 | 16 | 12 | 5 | 0.65 | 2 |
| A2 | 200 | 18 | 8 | 3 | 0.45 | 4 |
| A3 | 300 | 14 | 16 | 7 | 0.78 | 1 |
| A4 | 275 | 17 | 10 | 4 | 0.52 | 3 |
Python Script Usage
You can also import and use the package in your Python scripts:
from topsis_vansh_102203021 import topsis
topsis(
input_file="data.csv",
weights="1,1,2,3",
impacts="+,+,-,+",
output_file="result.csv"
)
Validation and Error Handling
The package includes robust error handling to ensure correct inputs:
-
File Not Found:
- If the input file does not exist, an appropriate error message is shown.
-
Invalid Parameters:
- The number of weights, impacts, and criteria must match.
-
Non-Numeric Values:
- From the second column onwards, only numeric values are allowed.
-
Invalid Impacts:
- Impacts must be either
+or-.
- Impacts must be either
-
Minimum Column Requirement:
- The input file must have at least three columns.
Example Files
You can test the package using the following example files:
Input File (data.csv):
| Alternatives | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 |
|---|---|---|---|---|
| A1 | 250 | 16 | 12 | 5 |
| A2 | 200 | 18 | 8 | 3 |
| A3 | 300 | 14 | 16 | 7 |
| A4 | 275 | 17 | 10 | 4 |
Output File (result.csv):
| Alternatives | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 | Topsis Score | Rank |
|---|---|---|---|---|---|---|
| A1 | 250 | 16 | 12 | 5 | 0.65 | 2 |
| A2 | 200 | 18 | 8 | 3 | 0.45 | 4 |
| A3 | 300 | 14 | 16 | 7 | 0.78 | 1 |
| A4 | 275 | 17 | 10 | 4 | 0.52 | 3 |
Author
Developed by Vansh Kansal (Roll Number: 102203021).
For any questions or feedback, please contact vanshkansal5@example.com.
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_vansh_102203021-0.1.1.tar.gz.
File metadata
- Download URL: topsis_vansh_102203021-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
444a7f56d7cd0911f2e4130160e7e9b031209df1645e79007ff7ab67cf7b7d1c
|
|
| MD5 |
c30d409fe5905ca42b0268aaf713b2e6
|
|
| BLAKE2b-256 |
ff96a53d266030b8ffaaf39a52543009903e6d40b60c934d1438ddcf163aa450
|
File details
Details for the file Topsis_Vansh_102203021-0.1.1-py3-none-any.whl.
File metadata
- Download URL: Topsis_Vansh_102203021-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7446ad4c539abdce9f20cd4a6f40aa9907e81ddaf6ca1b152e0b5cc27c51d31b
|
|
| MD5 |
9ed6bb822b758e0d259519fe82fc163b
|
|
| BLAKE2b-256 |
f4af1de931be0058b46c5b316842275e70a06de7a0f13477ca4981a2d17c794e
|