Skip to main content

Multiple criteria decision making for selection of best model

Project description

TOPSIS Implementation in Python

About TOPSIS

TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) is a multi-criteria decision analysis method which was originally developed by Hwang and Yoon in 1981. TOPSIS chooses the alternative that is the closest to the positive ideal solution and farthest from the negative ideal solution.

Installation

pip install topsis

Usage

The program accepts the following arguments:

  1. Input file (.csv)
  2. Weights (comma-separated)
  3. Impacts (comma-separated)
  4. Output file (.csv)
python topsis.py input.csv "1,1,1,2,2" "+,-,-,+,-" output.csv

Input File Format

Input file must contain three or more columns:

  • First column: Object/Variable name
  • Second to last columns: Criteria values
  • File must be a CSV file (.csv extension)

Sample input file:

Fund Name,P1,P2,P3,P4,P5
M1,0.68,0.48,13.07,0.74,0.87
M2,0.78,0.61,14.85,0.71,0.29
M3,0.61,0.37,14.01,0.71,0.95
M4,0.76,0.39,11.11,0.77,0.14
M5,0.59,0.41,11.32,0.82,0.55

Output Format

Output file contains all the columns of input file along with two additional columns having normalized scores and ranks.

Sample output file:

Fund Name,P1,P2,P3,P4,P5,Topsis Score,Rank
M1,0.68,0.48,13.07,0.74,0.87,0.7722,2
M2,0.78,0.61,14.85,0.71,0.29,0.6253,4
M3,0.61,0.37,14.01,0.71,0.95,0.8231,1
M4,0.76,0.39,11.11,0.77,0.14,0.5486,5
M5,0.59,0.41,11.32,0.82,0.55,0.6791,3

Parameters

Weights

Weights indicate the relative importance of each criterion. They should be provided as comma-separated values. Number of weights should be equal to number of criteria.

Example: "1,1,1,2,2"

Impacts

Impacts decide whether the criterion is to be maximized (+) or minimized (-). They should be provided as comma-separated values. Number of impacts should be equal to number of criteria.

Example: "+,-,-,+,-"

Error Handling

The program handles the following errors:

  • Input file does not exist
  • Input file is not a CSV file
  • Input file has less than 3 columns
  • Number of weights, impacts is not equal to number of criteria
  • Impacts are not either '+' or '-'
  • Non-numeric values in criteria columns

Example

Consider a real estate decision problem with the following criteria:

  1. Cost (-)
  2. Square footage (+)
  3. Distance to city center (-)
  4. Age of building (-)
  5. Number of rooms (+)
python topsis.py houses.csv "0.25,0.25,0.15,0.15,0.20" "-,+,-,-,+" output.csv

Dependencies

  • Python 3.x
  • Pandas
  • NumPy

License

This project is licensed under MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

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_parth_102203636-1.0.0.tar.gz (4.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_Parth_102203636-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: topsis_parth_102203636-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.1

File hashes

Hashes for topsis_parth_102203636-1.0.0.tar.gz
Algorithm Hash digest
SHA256 96d81856391afc91d5098cb415d39126013db8217e5b27c2026461972b74ad7c
MD5 3db3c77c541b9eb4208882e736a99bb4
BLAKE2b-256 5f2b2e3b998d0d857d23510ff0ed6ece17a47035e2edd5379a047796486d1a70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Topsis_Parth_102203636-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc44b2abac762c1107bf3d1bdaf604b1599efab749ba3576bf52e075797eca4f
MD5 6d5f8ec5c5e4bdc9b84431cfe5851513
BLAKE2b-256 5b03ffc61f8c170713e2247231eb08ec7e5cadf1c1774a4168195cf312fdaa7f

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