Skip to main content

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

Project description

TOPSIS-YourName-RollNumber

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

📋 Description

TOPSIS is a multi-criteria decision-making method that helps rank alternatives based on their similarity to the ideal solution. This package provides an easy-to-use implementation of the TOPSIS algorithm with comprehensive error handling and validation.

🎯 Features

  • ✅ Complete TOPSIS algorithm implementation
  • ✅ Command-line interface
  • ✅ Comprehensive input validation
  • ✅ Detailed error messages
  • ✅ CSV input/output support
  • ✅ Easy to use and integrate

📦 Installation

From PyPI

pip install Topsis-YourName-RollNumber

From Source

git clone https://github.com/yourusername/Topsis-YourName-RollNumber.git
cd Topsis-YourName-RollNumber
pip install -e .

🚀 Usage

Command Line

python -m Topsis-YourName-RollNumber <InputFile> <Weights> <Impacts> <OutputFile>

Example

python -m Topsis-YourName-RollNumber data.xlsx "1,1,1,2" "+,+,-,+" output.xlsx

As a Python Module

from Topsis_YourName_RollNumber import topsis_analysis

# Perform TOPSIS analysis
result_df = topsis_analysis(
    input_file='data.xlsx',
    weights='1,1,1,2',
    impacts='+,+,-,+',
    output_file='output.xlsx'
)

print(result_df)

📊 Input Format

Excel File Requirements (.xlsx)

  1. Minimum 3 columns: First column for alternatives (names), remaining columns for numeric criteria
  2. First column: Alternative names (non-numeric)
  3. Remaining columns: Numeric values only

Example Input File (data.xlsx)

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

Parameters

  • Weights: Comma-separated numeric values (e.g., "1,1,1,2")
  • Impacts: Comma-separated + or - signs (e.g., "+,+,-,+")
    • + : Benefit criterion (higher is better)
    • - : Cost criterion (lower is better)

📤 Output Format

The output Excel file contains all input columns plus:

  • Topsis Score: Performance score (0-1, higher is better)
  • Rank: Ranking (1 = best alternative)

Example Output

Fund Name P1 P2 P3 P4 P5 Topsis Score Rank
M5 0.94 0.88 3.6 62.2 16.91 0.6890 1
M8 0.93 0.87 5.5 53.3 15.07 0.6123 2
... ... ... ... ... ... ... ...

⚠️ Error Handling

The package validates:

  • ✅ Correct number of arguments
  • ✅ File existence
  • ✅ Excel format (.xlsx)
  • ✅ Minimum 3 columns
  • ✅ Numeric values in criteria columns
  • ✅ Matching number of weights and criteria
  • ✅ Matching number of impacts and criteria
  • ✅ Valid impact signs (+ or -)
  • ✅ Proper comma separation

🧮 TOPSIS Algorithm Steps

  1. Normalize the decision matrix
  2. Apply weights to normalized matrix
  3. Identify ideal best and ideal worst solutions
  4. Calculate Euclidean distances from ideal solutions
  5. Compute TOPSIS score
  6. Rank alternatives

📚 Mathematical Formula

TOPSIS Score:

$$P_i = \frac{S_i^-}{S_i^+ + S_i^-}$$

Where:

  • $S_i^+$ = Distance from ideal best
  • $S_i^-$ = Distance from ideal worst

🛠️ Requirements

  • Python >= 3.7
  • pandas >= 1.0.0
  • numpy >= 1.18.0
  • openpyxl >= 3.0.0

📄 License

MIT License

👤 Author

Your Name

🤝 Contributing

Contributions, issues, and feature requests are welcome!

📝 Changelog

Version 1.0.0 (Initial Release)

  • Complete TOPSIS implementation
  • CLI interface
  • Comprehensive validation
  • PyPI package

Made with ❤️ for Multi-Criteria Decision Making

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

Uploaded Source

Built Distribution

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

topsis_vaibhavi_102303784-1.0.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for topsis_vaibhavi_102303784-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8beed2ee8835416d371388bbbca2b381fe7c8c12511db75e2d5956ae4e442f5f
MD5 0c1d1d330e4e7d1a5b9f0ddbd2dbdeb5
BLAKE2b-256 e98aa79423c2cc836637dac1dbeae7dc6c9db647d024e6d9cfdc961de8852940

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_vaibhavi_102303784-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a141e2a4e25178909bc055735224baccf93934f9528242916bd6fc71b6cc408
MD5 2c939ce75caeae3794b719d823adf33c
BLAKE2b-256 18d96599ed0b5f1d6eebde222441be47023b84c46592b311ebf7a5a2166819eb

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