Skip to main content

A Python package implementing TOPSIS technique.

Project description

TOPSIS-Python

Submitted By: Bhavya Kakwani


What is TOPSIS

Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) originated in the 1980s as a multi-criteria decision making method. TOPSIS chooses the alternative of shortest Euclidean distance from the ideal solution, and greatest distance from the negative-ideal solution. More details at wikipedia.


How to use this package:

The Topsis-Bhavya-101903365 has a function topsis() that takes 4 parameters, i.e., inputFile, weights, impacts, and outputFile, and returns the resulting dataframe having Topsis Score and Rank as additional columns.

Where,

  • inputFile: Can be either csv file or pandas dataframe. Input file must contain three or more columns, where, First column is the object/variable name like M1, M2, M3, M4, etc. Also, from 2nd to last columns must contain numeric values only.
  • weights: In the form of string having numerical values separated by commas.
  • impacts: In the form of string having + or - values separated by commas. Here, + refers to positive impact, whereas, - refers to negative impact.
  • outputFile (optional): csv file in which output of the function will be stored.

For Example,

Method 1: By passing csv file as input

>>> import Topsis_Bhavya_101903365 as t
>>> inputFile = "input.csv"
>>> weights = "1,1,1,2,1"
>>> impacts = "+,+,-,+,+"
>>> result_df = t.topsis(inputFile, weights, impacts)

Method 2: By passing pandas dataframe as input

>>> import Topsis_Bhavya_101903365 as t
>>> import pandas as pd
>>> dataFrame = pd.read_csv("input.csv)
>>> weights = "1,1,1,2,1"
>>> impacts = "+,+,-,+,+"
>>> result_df = t.topsis(dataFrame, weights, impacts)

Sample Input

Dataset

Fund Name P1 P2 P3 P4 P5
M1 0.65 0.42 3.3 46.3 12.67
M2 0.81 0.66 4.9 51.4 14.44
M3 0.87 0.76 6 65.4 18.26
M4 0.87 0.76 4.2 40.7 11.63
M5 0.75 0.56 6.8 57.5 16.4
M6 0.64 0.41 5.3 44.7 12.76
M7 0.77 0.59 4.7 49.8 13.97
M8 0.7 0.49 3.1 43.9 12.05

Weights

weights = "1,1,1,2,1"

Impacts

impacts = "+,+,-,+,+"


Sample Output

Fund Name P1 P2 P3 P4 P5 Topsis Score Rank
M1 0.65 0.42 3.3 46.3 12.67 0.41202513 7
M2 0.81 0.66 4.9 51.4 14.44 0.510060544 2
M3 0.87 0.76 6 65.4 18.26 0.685105262 1
M4 0.87 0.76 4.2 40.7 11.63 0.433129944 5
M5 0.75 0.56 6.8 57.5 16.4 0.469643489 3
M6 0.64 0.41 5.3 44.7 12.76 0.225789842 8
M7 0.77 0.59 4.7 49.8 13.97 0.451566364 4
M8 0.7 0.49 3.1 43.9 12.05 0.418005937 6

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_Bhavya_101903365-1.0.1.tar.gz (3.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_Bhavya_101903365-1.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file Topsis_Bhavya_101903365-1.0.1.tar.gz.

File metadata

  • Download URL: Topsis_Bhavya_101903365-1.0.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.50.2 importlib-metadata/4.11.1 keyring/21.4.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5

File hashes

Hashes for Topsis_Bhavya_101903365-1.0.1.tar.gz
Algorithm Hash digest
SHA256 908953337acc348b944b1d9ccbc42ab8839787fcb4fd75b523adf519c1dafb3e
MD5 493e775f9ac9aebafcca238fe53ce7d9
BLAKE2b-256 dee0f6afaad04b3fdee9c2f948eb81ec73bcd9f3dc411aa5a15bfd38cb116d8a

See more details on using hashes here.

File details

Details for the file Topsis_Bhavya_101903365-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: Topsis_Bhavya_101903365-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.50.2 importlib-metadata/4.11.1 keyring/21.4.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5

File hashes

Hashes for Topsis_Bhavya_101903365-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0ec43c78efbb63deef25642482ae4ebfc996cfd0e822c1c2e699234dc7c426a
MD5 7e0bcec1227778d70d80ca6b3eb9aeca
BLAKE2b-256 60a319c5808422bdc903e58a76c0f19f86fec15d7187a658899c0a611dc77ebb

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