Skip to main content

Package for Topsis Score Calculation

Project description

TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a decision-making method used to rank options based on their closeness to the best possible choice. It works by comparing each option to an ideal solution, which has the best values for all criteria, and an anti-ideal solution, which has the worst values. The method calculates scores based on how close each option is to the ideal and how far it is from the worst. Simple and efficient, TOPSIS is often used in business, engineering, and management to make decisions when multiple factors need to be considered.

How it does it work?

Consider a scenario where you're evaluating different smartphone models based on attributes like price, storage capacity, camera performance, and design. Instead of relying on subjective judgment, TOPSIS helps by standardizing the data, assigning weights to each criterion (for instance, giving more importance to camera performance than design), and measuring how far each model is from an ideal solution. The model closest to the "ideal case" ranks the highest.

Necessities

To get started, ensure you have the following:

  • Python: Version 3.7 or higher (preferably).
  • Pandas: For data handling and manipulation.
  • NumPy: For numerical calculations.

To run the dependecies, run:

pip install pandas
pip install numpy 

How to run the script?

Command-Line Execution

Here is the command you will use to run the script:

topsis <inputFileName> <Weights> <Impacts> <resultFileName>

Where: inputFileName is your CSV file that holds the data. It should have one column for alternatives and the rest for decision-making criteria (e.g., price, storage, camera). Weights is a comma-separated string that specifies the importance (weight) of each criterion. Impacts is another comma-separated string, indicating whether a criterion is beneficial (+) or non-beneficial (-). resultFileName is where you want to save the output, containing the scores and ranks.

Example

Let us say we have a CSV file named input_data.csv and we want to weigh the features as 20%, 30%, 30%, and 20%, respectively, with the first three being beneficial and the last one (Looks) being non-beneficial.

Run:

topsis input_data.csv "0.2,0.3,0.3,0.2" "+,+,+,-" result.csv

This command will process the data, calculate the scores, and save the results in a file called result.csv.

Input Data

Model Price Storage Camera Looks
M1 250 16 12 5
M2 200 16 8 3
M3 300 32 16 4
M4 275 32 8 4
M5 225 16 16 2

Here, each row represents a different alternative (e.g., smartphone model) and each column represents a decision-making criterion.

Output Format

After running the decision-making script, the output includes the calculated Score and Rank for each model:

Model Price Storage Camera Looks Score Rank
M1 250 16 12 5 0.4459 4
M2 200 16 8 3 0.3700 5
M3 300 32 16 4 0.6299 1
M4 275 32 8 4 0.4936 2
M5 225 16 16 2 0.4758 3

Explanation

  • Score: The score is calculated based on a weighted evaluation of the decision-making criteria.
  • Rank: Models are ranked based on their scores, with 1 being the highest rank.

License:

This project is licensed under the MIT License. Feel free to use, modify, or contribute!

Project details


Release history Release notifications | RSS feed

This version

1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

topsis_102203992-1.1.tar.gz (4.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_102203992-1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file topsis_102203992-1.1.tar.gz.

File metadata

  • Download URL: topsis_102203992-1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.11

File hashes

Hashes for topsis_102203992-1.1.tar.gz
Algorithm Hash digest
SHA256 f7b5c0bdd6c3946eeb67ac4fb1a0671e30139267f393e2fa162e7de57bfdad01
MD5 bf8d940715c7ff69bb15b28d4cc6e785
BLAKE2b-256 01eb6061087499a5ed531b51eb3435c6c8a3cab7cae187a6f2f9bbe06a297222

See more details on using hashes here.

File details

Details for the file topsis_102203992-1.1-py3-none-any.whl.

File metadata

  • Download URL: topsis_102203992-1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.11

File hashes

Hashes for topsis_102203992-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 04d18d0e75f5c0a55829d169a28183d546d3eae90bce441b2a18a70cfef136ff
MD5 955b4fb8b7b5c7a1f1bf2631f8e864a4
BLAKE2b-256 e39624029ef273507515338e466d09526809ebffc178d7edeaae22a48635291e

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