Skip to main content

Multiple Criteria Decision Making

Project description

TOPSIS Analysis Package

A Python package for performing TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) analysis on numerical datasets. This package provides both a command-line interface and a importable module for performing TOPSIS analysis on datasets containing numerical data (int32, int64, float32, float64).

Overview

TOPSIS is a multi-criteria decision analysis method that helps identify the best alternative from a set of options based on multiple criteria. The package normalizes the input data, applies weights to different criteria, and considers whether each criterion should be maximized or minimized.

Installation

pip install topsis-102217133

Usage

As a Module

from topsis_analysis import run

# Perform TOPSIS analysis
result_df = run(
    input_df,           # pandas DataFrame with numerical values
    weights,            # List of weights for each criterion
    impacts,            # List of impacts ('+' or '-') for each criterion
)

Command Line Interface

python -m topsis_analysis <source_csv> <weights> <impacts> <output_csv>

Parameters

For Both Module and CLI:

  1. Input Data:

    • Must contain only numerical values (int32, int64, float32, float64)
    • First column will be used as index
    • No missing values allowed
  2. Weights:

    • Must sum to 1
    • Number of weights must match number of columns (excluding index)
    • Module: List of float values
    • CLI: Comma-separated values (e.g., "0.25,0.25,0.25,0.25")
  3. Impacts:

    • Use '+' for criteria to be maximized
    • Use '-' for criteria to be minimized
    • Number of impacts must match number of columns (excluding index)
    • Module: List of strings
    • CLI: Comma-separated signs (e.g., "-,+,+,+")

CLI Only:

  1. output_csv: Path where the result CSV will be stored

Example Usage

As a Module

import pandas as pd
from topsis_analysis import run

# Read input data
df = pd.read_csv('data.csv')

# Define weights and impacts
weights = [0.25, 0.25, 0.25, 0.25]
impacts = ['-', '+', '+', '+']

# Run TOPSIS analysis
result = run(df, weights, impacts)

# Save results if needed
result.to_csv('output.csv', index=False)

Command Line

python -m topsis-102217133 data.csv 0.25,0.25,0.25,0.25,0.25 -,+,+,+,+ output.csv

Input CSV Format

P1,P2,P3,P4,P5
0.62,0.38,5.7,47,13.43
0.8,0.64,5.4,38.6,11.36
0.83,0.69,3.3,57.9,15.68
0.84,0.71,5.5,52.3,14.84
0.72,0.52,4.6,44.8,12.66
0.61,0.37,7,41.2,12.3
0.61,0.37,3.9,46.7,12.9
0.93,0.86,6.5,35.4,10.92
  • Weights not summing to 1

Output Format

P1,P2,P3,P4,P5,euclidean_distance_worst,euclidean_distance_best,performance_score,rank
0.29077553802544853,0.22636699320773462,0.37551232309446086,0.361269319952853,0.36248022622053017,0.18911380785500428,0.350388690096909,0.35053370201792894,7
0.375194242613482,0.3812496727709215,0.35574851661580503,0.296702037237875,0.30661022858266734,0.29757811013334073,0.18096741720614892,0.6218386613866165,2

Error Handling

The package provides comprehensive error handling for:

  • Invalid number of weights or impacts
  • Invalid data types
  • Missing values in the dataset
  • Invalid file paths (CLI only)
  • Non-numeric data in columns
  • Invalid impact symbols

Dependencies

  • Python 3.7+
  • pandas
  • numpy

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

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_tarun_102217133-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_Tarun_102217133-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: topsis_tarun_102217133-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.11.3

File hashes

Hashes for topsis_tarun_102217133-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b91c9d29afe262ebadf13d2fe89429f828de3dd032873747f5b8dd6d21284167
MD5 bfb8da33fd3adaaad35e7a2add9c0f88
BLAKE2b-256 c614d5affabf477b25fc16d0b8d1d27418ff9c5c2be2d2a54b9f43d8d36d6fe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_Tarun_102217133-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e69f7443d6ee247f1f336f98058bd46e080124c57eeed49d41a45b91ef33535
MD5 c910596f5d5b5327285fa49f1f550c19
BLAKE2b-256 a31b5b4ae828f563f81ab2fc48156f44fdbb8482d3d56645206fdf830f676f71

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