Skip to main content

Topsis Score Calculator

Project description

Topsis Score Calculator (topsisAnant102003755)

For: Assignment - Topsis (UCS654)  Submitted by: Anant Mishra  Roll no: 102003755  Subgroup: 3COE25

Description

Topsis

TOPSIS (Technique for order performance by similarity to ideal solution) is a useful technique in dealing with multi-attribute or multi-criteria decision making (MADM/MCDM) problems in the real world. It is a method of ranking alternatives, which are represented by vectors in a multi-dimensional space. The method is based on the Euclidean distance between the alternatives and the ideal and negative-ideal solutions.

topsisAnant102003755

This is a python library for calculating the Topsis score of a given csv file. It takes the csv file name, weights vector and impacts vector as input and returns the Topsis score and rank of each row in the csv file.

Installation

Using package manager pip install topsisAnant102003755.

pip install topsisAnant102003755

Usage

In code as a library

Input

from topsis.topsis import topsis

# Weights and Impacts are accepted in both list and string format
df = topsis.calculate("sample.csv", "0.25,0.25,0.25,0.25", "+,+,-,+", output_file="output.csv", verbose = True, force=True)

# OR
df = topsis.calculate("sample.csv", [0.25,0.25,0.25,0.25], ['+','+','-','+'], output_file="output.csv", verbose = True, force=True)

Output


Top 5 attributes with highest topsis score:
+-------------------------+-----------------+-----------------+----------+---------+----------------+--------+
| Attribute Or Criteria   |   Price or Cost |   Storage Space |   Camera |   Looks |   Topsis Score |   Rank |
|-------------------------+-----------------+-----------------+----------+---------+----------------+--------|
| Mobile 4                |             275 |              32 |        8 |       4 |         0.796  |      1 |
| Mobile 3                |             300 |              32 |       16 |       4 |         0.5776 |      2 |
| Mobile 1                |             250 |              16 |       12 |       5 |         0.5343 |      3 |
| Mobile 2                |             200 |              16 |        8 |       3 |         0.4224 |      4 |
| Mobile 5                |             225 |              16 |       16 |       2 |         0.0727 |      5 |
+-------------------------+-----------------+-----------------+----------+---------+----------------+--------+

Commandline usage

topsis -i <csv file name> -w=<weights vector> -p=<impacts vector> -o <output file name> -f

Arguments

  • -i, --input: csv file name
  • -w, --weights: weights vector
  • -p, --impacts: impacts vector
  • -o, --output: output file name
  • -f, --force: force overwrite of output file

Help

$ topsis -h

usage: topsis [-h] -i INPUT [-o OUTPUT] [-w WEIGHTS] [-p IMPACTS] [-f]

Topsis Score Calculator

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Input file path in csv or xlsx format
  -o OUTPUT, --output OUTPUT
                        Output file path in csv or xlsx format
  -w WEIGHTS, --weights WEIGHTS
                        Weights separated by comma
  -p IMPACTS, --impacts IMPACTS
                        Impacts separated by comma (either + or -)
  -f, --force           Overwrite output file if it already exists

Example

sample.csv

A csv file showing data for different mobile handsets having varying features.

Model Storage space(in gb) Camera(in MP) Price(in $) Looks(out of 5)
Mobile 1 16 12 250 5
Mobile 2 16 8 200 3
Mobile 3 32 16 300 4
Mobile 4 32 8 275 4
Mobile 5 16 16 225 2

weights vector = [ 0.25 , 0.25 , 0.25 , 0.25 ]

impacts vector = [ + , + , - , + ]

Input:

topsis -i mydata.csv -w="0.25,0.25,0.25,0.25" -p="+,+,-,+" -o output.csv -f

Output:

Weights:  [0.25 0.25 0.25 0.25]
Impacts:  ['+' '+' '-' '+']

Top 5 attributes with highest topsis score:
+-------------------------+-----------------+-----------------+----------+---------+----------------+--------+
| Attribute Or Criteria   |   Price or Cost |   Storage Space |   Camera |   Looks |   Topsis Score |   Rank |
|-------------------------+-----------------+-----------------+----------+---------+----------------+--------|
| Mobile 4                |             275 |              32 |        8 |       4 |         0.796  |      1 |
| Mobile 3                |             300 |              32 |       16 |       4 |         0.5776 |      2 |
| Mobile 1                |             250 |              16 |       12 |       5 |         0.5343 |      3 |
| Mobile 2                |             200 |              16 |        8 |       3 |         0.4224 |      4 |
| Mobile 5                |             225 |              16 |       16 |       2 |         0.0727 |      5 |
+-------------------------+-----------------+-----------------+----------+---------+----------------+--------+

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

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

topsisAnant102003755-1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

topsisAnant102003755-1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file topsisAnant102003755-1.2.tar.gz.

File metadata

  • Download URL: topsisAnant102003755-1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for topsisAnant102003755-1.2.tar.gz
Algorithm Hash digest
SHA256 8415b48954273a9a27f23109105ea4ace795a41cc9efc56e345328879d4ce079
MD5 cc5507a5457bd98e5dfd3e41ec708638
BLAKE2b-256 ea300c88fa3471b37b702f556eb73a64c5c0871eaa07874b5439390895a65419

See more details on using hashes here.

File details

Details for the file topsisAnant102003755-1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for topsisAnant102003755-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e2c0b47a124d6107733d2f81a4765975842d82b69ed26884524a287d7f2b4543
MD5 d0bcc3d21d5d049a862bdc8d382c6975
BLAKE2b-256 2cf49ede84fb9226fa41dd1f81899c1bd1f209b34636afaf2644c54005dfdf75

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