Skip to main content

It Ranks the Models based on MCDM

Project description

Project Description

TOPSIS Implementation

This python package is submitted by Kirtan Dwivedi; Roll No.- 102203600

Overview

TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) is a multi-criteria decision-making (MCDM) method. This Python package implements the TOPSIS method, allowing you to rank alternatives based on multiple criteria.

This implementation is specifically designed to work with a CSV input file and provides results with TOPSIS scores and ranks.

Features

  • Handles multi-criteria decision-making problems
  • Accepts CSV input files
  • Outputs a CSV file with TOPSIS scores and ranks
  • Validates input data and handles common errors
  • Command-line interface for ease of use

Guide Video and Web Service for Topsis.

For a detailed guide, you can watch this Topsis package in python by Kirtan Dwivedi and check this Topsis-Kirtan-102203600 for direct use.

If you have any questions, suggestions, or issues, feel free to comment.

OR

Installation

You can install this package directly from PyPI using pip:

pip install Topsis-Kirtan-102203600

Usage

Command-Line Interface

After installing the package, you can use it from the command line. The basic usage is:

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

Parameters

  • InputDataFile: The path to the input XLSX file containing the data.
  • Weights: A string of comma-separated numerical weights (e.g., "1,1,1,2").
  • Impacts: A string of comma-separated + or - signs indicating whether each criterion is beneficial (+) or non-beneficial (-) (e.g., "+,+,-,+").
  • ResultFileName: The path to the output CSV file where results will be saved.

Example

Suppose you have an input file named 102203600_data.xlsx with the following content:

| Alternative | Criterion1 | Criterion2 | Criterion3 | Criterion4 |
|-------------|------------|------------|------------|------------|
| M1          | 250        | 16         | 12         | 5          |
| M2          | 200        | 6          | 8          | 3          |
| M3          | 300        | 16         | 8          | 4          |
| M4          | 275        | 10         | 10         | 4          |

You can run the following command:

topsis 102203600_data.xlsx "1,1,1,2" "+,+,-,+"  102203600_result.csv

This will generate a file 102203600_result.csv containing the input data along with two additional columns for the TOPSIS score and the rank:

| Alternative | Criterion1 | Criterion2 | Criterion3 | Criterion4 | TOPSIS Score | Rank |
|-------------|------------|------------|------------|------------|--------------|------|
| M1          | 250        | 16         | 12         | 5          | 0.556        | 2    |
| M2          | 200        | 6          | 8          | 3          | 0.222        | 4    |
| M3          | 300        | 16         | 8          | 4          | 0.778        | 1    |
| M4          | 275        | 10         | 10         | 4          | 0.444        | 3    |

Error Handling

The program includes several checks to handle common errors:

  • Correct number of parameters (inputFileName, Weights, Impacts, resultFileName).
  • Show the appropriate message for wrong inputs.
  • Handling of “File not Found” exception
  • Input file must contain three or more columns.
  • From 2nd to last columns must contain numeric values only (Handling of non-numeric values) -Number of weights, number of impacts and number of columns (from 2nd to last columns) must be same.
  • Impacts must be either +ve or -ve.
  • Impacts and weights must be separated by ‘,’ (comma).

Examples

Example 1: Basic Usage

python topsis data.xlsx "1,1,1,1" "+,+,+,+" result.csv

Example 2: Different Weights and Impacts

python topsis data.xlsx "0.5,1,1.5,2" "+,-,+,-" result.csv

Example 3: Handling Errors

If the number of weights or impacts does not match the number of criteria:

python topsis data.xlsx "1,1,1" "+,+" result.csv

This will result in an error message indicating the mismatch.

Testing

To ensure everything works correctly, you can run some tests. If you haven't already, you can clone the repository and run the tests locally.

# Clone the repository
git clone https://github.com/KirtanDwivedi/Topsis-Kirtan-102203600

# Navigate to the project directory
cd Topsis_Kirtan_102203600

# Install the required dependencies
pip install -r requirements.txt

# Run the tests (assuming you've created test scripts)
python -m unittest discover tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Inspired by the original TOPSIS method developed by C.L. Hwang and K. Yoon.

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_kirtan_102203600-1.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

Topsis_Kirtan_102203600-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file topsis_kirtan_102203600-1.0.0.tar.gz.

File metadata

  • Download URL: topsis_kirtan_102203600-1.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for topsis_kirtan_102203600-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8e92646840ac8fba1d5b97559f3334c9c27e836bb0551214b15bf59c1e5ab452
MD5 8066dafd68a11f5f88a6319aafb73caa
BLAKE2b-256 a5bff02d7cc0313a1436a2a1e71b0350be0e88adb2862633f109d71e668e1dd5

See more details on using hashes here.

File details

Details for the file Topsis_Kirtan_102203600-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for Topsis_Kirtan_102203600-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40851ea212abf94e6434fd98c7b5f46ed4341c52aaf5e107f073a1420f7ceb2b
MD5 300ea28b8f1cdbe3c8952a22c9a59f7f
BLAKE2b-256 f60b23d265878c5ac830de4a8b10313021ee8bf9adccf9a71b2d9fe9aa933831

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