Skip to main content

102303812-topsis

A Python package to implement TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) for multi-criteria decision analysis.

Author: Harsh Tanwar
Roll No: 102303812
Email: htanwar_be23@thapar.edu

Repository: Assignment1-Topsis


What is TOPSIS?

TOPSIS ranks alternatives by comparing each to an ideal positive and ideal negative solution. Alternatives closer to the ideal positive and farther from the ideal negative get higher scores and better ranks. The method uses vector normalization, weighted criteria, and Euclidean distances to compute a performance score for each alternative.


Requirements

  • Python 3.6+
  • pandas – data handling
  • numpy – numerical operations

Install dependencies:

pip install pandas numpy

Installation

From PyPI (if published)

pip install 102303812-topsis

From source (clone or download the repo)

git clone https://github.com/htan11/course-materials.git
cd course-materials/UCS654/Assignment1-Topsis
pip install .

Or, in the folder containing setup.py:

pip install .

Usage

Command line

topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>

Example (with 5 criteria):

topsis data.csv "1,1,1,1,1" "+,+,-,+,-" result.csv

As a Python module

(Because the package name contains a hyphen, use importlib to import.)

import importlib
topsis = getattr(importlib.import_module("102303812-topsis"), "topsis")

topsis("data.csv", "1,1,1,1,1", "+,+,-,+,-", "result.csv")

Parameters

Parameter Description
InputDataFile Path to a CSV file: first column = alternative names, remaining columns = numeric criterion values. Must have a header row.
Weights Comma-separated weights for each criterion (e.g. "1,1,1,2,1"). Number of values must match number of criteria.
Impacts Comma-separated impacts: + for beneficial (higher is better), - for non-beneficial (lower is better). Same count as criteria.
OutputResultFileName Path for the output CSV. Contains original columns plus Topsis Score and Rank.
  • Beneficial (+): e.g. Quality, Customer Rating — higher value is better.
  • Non-beneficial (-): e.g. Price, Delivery Time — lower value is better.

Input file format

CSV with a header; first column = alternative names, rest = numeric only.

Example (data.csv):

Product Quality Price Features Customer Rating Delivery Time
A1 8.5 450 7.2 4.3 3
A2 7.8 380 8.1 4.5 5
... ... ... ... ... ...
  • Column 1: labels (not used in math).
  • Columns 2–6: criteria. Weights and impacts must be given for each of these in order.

Example with this dataset

For 5 criteria (Quality, Price, Features, Customer Rating, Delivery Time):

  • Weights: "1,1,1,1,1" (equal weight).
  • Impacts: "+,+,-,+,-" (Quality +, Price +, Features -, Customer Rating +, Delivery Time -).

Run:

topsis data.csv "1,1,1,1,1" "+,+,-,+,-" result.csv

Output CSV will have all input columns plus:

  • Topsis Score – higher is better.
  • Rank – 1 = best alternative.

Output

The result file contains:

  • All original columns.
  • Topsis Score – performance score in [0, 1].
  • Rank – integer rank (1 = best).

Example message: Result file 'result.csv' created successfully.


Project structure

assignment1_DS-main/
├── README.md
├── setup.py
├── data.csv              # Sample input
├── 102303812-topsis/
│   ├── __init__.py
│   └── topsis.py         # TOPSIS implementation
└── LICENSE

License

MIT License. See LICENSE for details.

Metadata

Release files for Topsis-HarshTanwar-102303812 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Topsis-HarshTanwar-102303812 1.0.0
File Size Uploaded Provenance
topsis_harshtanwar_102303812-1.0.0.tar.gz 6.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for Topsis-HarshTanwar-102303812 1.0.0
File Interpreter ABI Platform
topsis_harshtanwar_102303812-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / topsis_harshtanwar_102303812-1.0.0.tar.gz

Download URL topsis_harshtanwar_102303812-1.0.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fe02e35c738498846baeeaa875f0f883ca36f9856ed502c4cdf68c8a59ddad34
BLAKE2b-256 checksum
How to use checksums
736657005a5c5a9a573618e02e43dc9161fa0af08e64f0db0e7718bf106bb3c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / topsis_harshtanwar_102303812-1.0.0-py3-none-any.whl

Download URL topsis_harshtanwar_102303812-1.0.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c03359a196b148dc227c829b8d962831e3896535a0774223eda225c7f0a15bb0
BLAKE2b-256 checksum
How to use checksums
9809ec31083dd7b564d8f4c1076a4b70c1ecf646ce3ea965741f911140fea10d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for Topsis-HarshTanwar-102303812 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page