Skip to main content

A Python package for TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) analysis

Project description

Topsis-Pratham-102303052

A Python package for performing TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) analysis on multi-criteria decision-making problems.

Author: Pratham Garg
Roll Number: 102303052

What is TOPSIS?

TOPSIS is a multi-criteria decision analysis method that helps in selecting the best alternative from a set of alternatives based on multiple criteria. It works by finding the alternative that is closest to the ideal solution and farthest from the negative-ideal solution.

Installation

pip install Topsis-Pratham-102303052

Usage

Command Line Interface

After installation, you can use the topsis command directly from the command line:

topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>

Example

topsis data.csv "1,1,1,2" "+,+,-,+" output-result.csv

Parameters

  • InputDataFile: Path to the CSV file containing the decision matrix

    • First column: Names of alternatives
    • Remaining columns: Criteria values (must be numeric)
  • Weights: Comma-separated weights for each criterion

    • Example: "1,1,1,2"
  • Impacts: Comma-separated impacts for each criterion

    • Use '+' for benefit criteria (higher is better)
    • Use '-' for cost criteria (lower is better)
    • Example: "+,+,-,+"
  • OutputResultFileName: Path where the result file will be saved

Input File Format

The input CSV file should have the following structure:

Fund Name P1 P2 P3 P4 P5
M1 0.67 0.45 6.5 42.6 12.56
M2 0.6 0.36 3.6 53.3 14.47
M3 0.79 0.61 6.4 63.1 17.84

Output File Format

The output file will contain all input columns plus two additional columns:

  • Topsis Score: The calculated TOPSIS score for each alternative
  • Rank: The rank of each alternative (1 = best)

Validation

The package performs the following validations:

  • Correct number of parameters
  • File existence check
  • Minimum 3 columns in input file
  • Numeric values in all columns except the first
  • Matching number of weights, impacts, and criteria columns
  • Valid impact values ('+' or '-')

Error Handling

The package provides clear error messages for:

  • Missing or incorrect parameters
  • File not found
  • Non-numeric values in criteria columns
  • Mismatch in number of weights/impacts/columns
  • Invalid impact values

Algorithm

The TOPSIS algorithm follows these steps:

  1. Normalization: Vector normalization of the decision matrix
  2. Weighted Normalization: Multiply normalized values by weights
  3. Ideal Solutions: Determine ideal best and ideal worst solutions
  4. Distance Calculation: Calculate Euclidean distances from ideal solutions
  5. TOPSIS Score: Calculate relative closeness to ideal solution
  6. Ranking: Rank alternatives based on TOPSIS scores

License

MIT License

Author

Pratham Garg
Roll Number: 102303052
Email: pgarg7_be23@thapar.edu

Links

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please open an issue on the GitHub repository.

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_pratham_102303052-1.0.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

topsis_pratham_102303052-1.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file topsis_pratham_102303052-1.0.2.tar.gz.

File metadata

File hashes

Hashes for topsis_pratham_102303052-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c6bef5bb56740fd52fb3bbabc1c2dc7b807b9d3ee06ff7fec01d4e2cb533d6f2
MD5 4a51251e961bccbb24a4c99f19692ed4
BLAKE2b-256 b91fca7532aa7cd8b8311d992edd9ec84a735488d8afd05c5417e527b3968cc3

See more details on using hashes here.

File details

Details for the file topsis_pratham_102303052-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for topsis_pratham_102303052-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c10ca4eff5caf29936ab3c6ace018aa4040d6143a0d267e6a4e7b3cb04de2793
MD5 45ac02c072698a41aa4b5957d861d6c3
BLAKE2b-256 8c19e8b966ebd470ffa9ba2c43b35209e197aac95255e8c47e1ca2442958399f

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