Skip to main content

A Python implementation of the TOPSIS decision-making method

Project description

README

TOPSIS Analysis in Jupyter Notebook

This README provides step-by-step instructions on how to use the TOPSIS package in a Jupyter Notebook.


Installation

Before running the TOPSIS function, ensure the package is installed. You can either install it from PyPI or locally:

From PyPI:

!pip install Topsis_102216076_Armandeep_Singh_Dhillon

Locally:

If the package is not uploaded to PyPI, navigate to the folder containing the setup.py file and run:

!pip install .

Usage

Step 1: Import the Package

Use the following code to import the topsis function:

from Topsis_102216076_Armandeep_Singh_Dhillon import topsis

Step 2: Prepare Input Data

Ensure you have a CSV file (e.g., data.csv) with the following structure:

  1. First column: Object/variable names (e.g., M1, M2, M3).
  2. Second to last columns: Numeric data for evaluation.

Example CSV (data.csv):

Object Criterion 1 Criterion 2 Criterion 3 Criterion 4
M1 250 16 12 5
M2 200 12 15 8
M3 300 18 10 6
M4 275 20 14 7

Step 3: Define Inputs

Specify the following parameters:

  • input_file: Path to the CSV file (e.g., data.csv).
  • weights: Comma-separated weights for the criteria (e.g., 1,1,1,2).
  • impacts: Comma-separated impacts (+ for beneficial, - for non-beneficial, e.g., +,+,-,+).
  • output_file: Name of the output file to save the results (e.g., result.csv).

Step 4: Run the TOPSIS Function

Use the following code to run the TOPSIS analysis:

# Import the necessary function
from Topsis_102216076_Armandeep_Singh_Dhillon import topsis

# Define inputs
input_file = "data.csv"
weights = "1,1,1,2"
impacts = "+,+,-,+"
output_file = "result.csv"

# Run TOPSIS
topsis(input_file, weights, impacts, output_file)

# Display the output file (optional)
import pandas as pd
result = pd.read_csv(output_file)
print(result)

Step 5: Output

The output CSV file (result.csv) will include all original columns, along with two additional columns:

  1. Topsis Score: The computed TOPSIS score for each object.
  2. Rank: The rank of each object based on the TOPSIS score (higher score = better rank).

Example Output (result.csv):

Object Criterion 1 Criterion 2 Criterion 3 Criterion 4 Topsis Score Rank
M1 250 16 12 5 0.85 1
M2 200 12 15 8 0.65 3
M3 300 18 10 6 0.70 2
M4 275 20 14 7 0.60 4

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

Built Distribution

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

File details

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

File metadata

File hashes

Hashes for topsis_armandeep_singh_dhillon_102216076-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b88acccce396108ac8f484b953a0bde0581e15509fd124ff0d26b0aa141b5e4
MD5 ad928219bae6a0bec285c0b939770ef6
BLAKE2b-256 2d9a91983752a2f82021cbb9f0c058ae30ef5c25c6ca1636372da70b1895a83b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Topsis_Armandeep_Singh_Dhillon_102216076-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baf68fbd5ec2f854651ed50a07ccc61e168237b3091ebc7cd2911f684a2c7916
MD5 26532ff592c9d7a3f5b99161548a1e25
BLAKE2b-256 c209dfbaed13a8f4238d60aa3b47f7249127ebaf932980d271fa1e7863139991

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