Skip to main content

A Python package for implementing the Topsis method

Project description

Topsis-Vivek-102203871

This Python package implements the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) decision-making method. It helps evaluate and rank alternatives based on multiple criteria, supporting both CSV and Excel file formats.

Features

  • Simple command-line interface.
  • Supports both .csv and .xlsx input formats.
  • Allows specifying weights and impacts for decision criteria.
  • Outputs the Topsis score and rank for each alternative.

Installation

To install the package, use pip (Python package manager). Run the following command in your terminal:

pip install Topsis-Vivek-102203871

STEPS

Step 1: Prepare Your Input Data The input file should have at least 3 columns:

The first column should represent the alternatives/objects (e.g., M1, M2, M3, etc.). The second column and beyond should contain numeric values representing the criteria for each alternative. Example Input Data (CSV format) Fund Name, P1, P2, P3, P4, P5 M1, 0.84, 0.71, 6.7, 42.1, 12.59 M2, 0.91, 0.83, 7.0, 31.7, 10.11 M3, 0.79, 0.62, 4.8, 46.7, 13.23 M4, 0.78, 0.61, 6.4, 42.4, 12.55 M5, 0.94, 0.88, 3.6, 62.2, 16.91 Example Input Data (Excel format) Alternatively, you can provide the data in Excel (.xlsx) format.

Step 2: Define Weights and Impacts Weights: The relative importance of each criterion (must be comma-separated). Impacts: The direction of preference for each criterion (+ for benefit, - for cost). Example Weights and Impacts Weights: "0.25, 0.25, 0.25, 0.25" Impacts: "+,+,-,+" Step 3: Running the Command Once your input data is ready, you can run the package using the command line. The format is:

python -m Topsis_Vivek_102203871 <input_file> <weights> <impacts> <result_file>

Example Command

python -m Topsis_Vivek_102203871 102203871-data.xlsx "0.25, 0.25, 0.25, 0.25" "+,+,-,+" 102203871-result.csv

Where:

102203871-data.xlsx is the input file (can be .csv or .xlsx). "0.25, 0.25, 0.25, 0.25" represents the weights of each criterion. "+,+,-,+" represents the impacts of each criterion. 102203871-result.csv is the output file where results will be saved. Step 4: Understanding the Output The output file will contain:

The original data. Two additional columns: Topsis Score: The computed score for each alternative. Rank: The rank based on the Topsis score (lower score = better rank). Example Output (CSV):

Fund Name, P1, P2, P3, P4, P5, Topsis Score, Rank M1, 0.84, 0.71, 6.7, 42.1, 12.59, 0.865, 2 M2, 0.91, 0.83, 7.0, 31.7, 10.11, 0.799, 3 M3, 0.79, 0.62, 4.8, 46.7, 13.23, 0.935, 1 M4, 0.78, 0.61, 6.4, 42.4, 12.55, 0.876, 4 M5, 0.94, 0.88, 3.6, 62.2, 16.91, 0.980, 5 The Topsis Score column represents how close each alternative is to the ideal solution, and the Rank column indicates the rank based on the Topsis score.

How it works

How the Package Works Normalization: The decision matrix is normalized using vector normalization. Weighted Matrix: The normalized matrix is weighted according to the user-defined weights. Ideal Solutions: The positive and negative ideal solutions are determined based on the direction of the impacts. Topsis Score: The Topsis score is calculated using the distance between the alternatives and the ideal solutions. Rank: The alternatives are ranked based on the calculated Topsis score. Error Handling The package performs the following validations:

File Not Found: Checks if the input file exists. Correct Number of Parameters: Ensures that the number of command-line arguments is correct. Valid Weights: Ensures that the weights are numeric and properly formatted. Valid Impacts: Ensures that the impacts contain only + or -. Valid Input Data: Ensures that the data columns contain only numeric values (except the first column).

License

This package is distributed under the MIT License. See LICENSE.txt for more details.

Contact

For any questions or issues, feel free to contact me at atrivivek001@gmail.com.

Summary

  • This README.md provides a full guide on how to install, use, and understand the Topsis-Vivek-102203871 package.
  • It includes clear instructions, example inputs/outputs, and error handling.

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_vivek_102203871-1.0.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

Topsis_Vivek_102203871-1.0.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file topsis_vivek_102203871-1.0.3.tar.gz.

File metadata

  • Download URL: topsis_vivek_102203871-1.0.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for topsis_vivek_102203871-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9a2c7449f1d5b3a92d5035b9fa80656553a485914bd4ac519bb368c90e1228ec
MD5 2a917d961926029195ea1a3f50921242
BLAKE2b-256 175a3226b647dc929ac076f876bdeb1988d57b9ceb87881073410488eac098a5

See more details on using hashes here.

File details

Details for the file Topsis_Vivek_102203871-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for Topsis_Vivek_102203871-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d46a0a43a488e4c5c056d9b0d7fce797a5bcee03242eae57f4b05fd19b0fcebe
MD5 c03655e67dda9c6fb65903f5ada6dd0d
BLAKE2b-256 ab54f5bf61d7180ccd01a2570061c159ec6f9907c4eeb7e2044b8d34f7d3a37b

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