Skip to main content

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

Project description

Topsis-Tatvam-102303484

TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) implementation in Python for multi-criteria decision analysis.

Description

TOPSIS is a multi-criteria decision analysis method that ranks alternatives based on their similarity to the ideal solution. This package provides a simple command-line tool to perform TOPSIS analysis on CSV data files.

Installation

Install the package using pip:

pip install Topsis-Haryiank-102303088

Usage

After installation, you can use the topsis command from anywhere in your terminal:

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

Parameters

  • InputDataFile: Path to the input CSV file
  • Weights: Comma-separated weights for each criterion (e.g., "1,1,1,2")
  • Impacts: Comma-separated impacts for each criterion ('+' for maximize, '-' for minimize)
  • OutputResultFileName: Path for the output CSV file

Example

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

This command:

  • Reads data from data.csv
  • Applies weights: 1, 1, 1, 2 to the four criteria
  • Maximizes criteria 1, 2, 4 and minimizes criterion 3
  • Saves results to result.csv

Input File Format

The input CSV file must follow this structure:

  • First column: Names of alternatives/options
  • Remaining columns: Numeric values for each criterion
  • Minimum: 3 columns (1 name column + at least 2 criteria)

Example Input (data.csv)

Model,Price,Storage,Camera,Battery
P1,250,64,12,4000
P2,200,32,8,3500
P3,300,128,16,4500
P4,275,64,12,4200
P5,225,32,16,3800

Output Format

The output CSV includes all original columns plus:

  • Topsis Score: Score between 0 and 1 (higher is better)
  • Rank: Ranking based on TOPSIS score (1 is best)

Example Output (result.csv)

Model,Price,Storage,Camera,Battery,Topsis Score,Rank
P3,300,128,16,4500,0.691,1
P4,275,64,12,4200,0.535,2
P1,250,64,12,4000,0.534,3
P5,225,32,16,3800,0.401,4
P2,200,32,8,3500,0.308,5

Weights and Impacts

Weights

Weights represent the relative importance of each criterion:

  • Must be numeric values
  • Comma-separated
  • Number of weights must match number of criteria
  • Example: "1,2,1,3" means criterion 2 is twice as important as criterion 1

Impacts

Impacts indicate whether a criterion should be maximized or minimized:

  • '+': Higher values are better (e.g., performance, storage, battery)
  • '-': Lower values are better (e.g., price, weight, power consumption)
  • Comma-separated
  • Number of impacts must match number of criteria
  • Example: "+,+,-,+"

How TOPSIS Works

  1. Normalize the decision matrix using vector normalization
  2. Apply weights to the normalized matrix
  3. Identify ideal best and ideal worst solutions for each criterion
  4. Calculate Euclidean distance of each alternative from ideal best and ideal worst
  5. Compute TOPSIS score: Score = Distance_to_worst / (Distance_to_best + Distance_to_worst)
  6. Rank alternatives based on TOPSIS scores (higher score = better rank)

Error Handling

The package validates:

  • ✓ Correct number of command-line arguments
  • ✓ Input file existence
  • ✓ Minimum 3 columns in input file
  • ✓ All criteria columns contain numeric values only
  • ✓ Number of weights matches number of criteria
  • ✓ Number of impacts matches number of criteria
  • ✓ Impacts are only '+' or '-'

Requirements

  • Python 3.6+
  • pandas >= 1.0.0
  • numpy >= 1.18.0

License

MIT License - see LICENSE file for details

Author

Tatvam Jain

Version

1.0.2

Links

Support

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

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

Uploaded Source

Built Distribution

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

topsis_tatvam_102303484-1.0.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: topsis_tatvam_102303484-1.0.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for topsis_tatvam_102303484-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e67477d0f04a5141888da34cd39f298cd4fe3d89a305ae8afd38fe908fc95604
MD5 eacf72d237b07b824c70426dd340e6fd
BLAKE2b-256 6cb5c6a3079b0794c7d7394c46cce9dea3db099416f7571e25fa06ff3e454ee2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_tatvam_102303484-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 86095937a03ff2964aa4d86f17266f55a47e9b2ae9c8d2cb211aafce4d134bcc
MD5 fbe45768b4e60d3902aeef2569324dfc
BLAKE2b-256 51fa4f3eb66690c0ee10eb151cdb5ab49c69c0b9e8a6d63c11d6391ebd6d77c4

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