A Python package for TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) multi-criteria decision analysis
Project description
TOPSIS Multi-Criteria Decision Analysis System
End-to-end implementation of the TOPSIS algorithm — from a pip-installable Python package to a deployed REST API with a web interface.
What This Project Covers
| Part | What I Built | Tech |
|---|---|---|
| I | TOPSIS algorithm from scratch + CLI tool | Python, NumPy, Pandas |
| II | Published Python package to PyPI | setuptools, pip, PyPI |
| III | REST API + Web Interface | Flask, HTML/CSS/JS |
The Algorithm — TOPSIS
TOPSIS ranks decision alternatives by measuring how close each is to the ideal best and how far from the ideal worst.
Steps:
- Normalize the decision matrix
- Apply criterion weights
- Compute positive and negative ideal solutions
- Calculate Euclidean distances to each ideal
- Compute performance scores → rank
Score(i) = D_worst(i) / (D_best(i) + D_worst(i))
Part I — CLI Tool
Install
pip install Topsis-Niyati-102303356
Usage
topsis <InputFile.csv> <Weights> <Impacts> <OutputFile.csv>
# Example
topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
Input CSV format
Model,Storage,Price,Camera,Battery
M1,16,2,3,4
M2,16,2.5,4,4
M3,32,3,4,5
- Column 1: alternative names
- Columns 2+: numeric criteria values
Output CSV format
Original data + two new columns: Topsis Score and Rank
Validations
- Correct number of CLI arguments
- File exists and is readable
- Input file has ≥ 3 columns
- Columns 2–n are numeric only
- Weights and impacts count matches column count
- Impacts are
+or-only - Weights are positive numbers
Part II — PyPI Package
Package: Topsis-Niyati-102303356
Use as a library
import pandas as pd
from topsis import topsis
data = pd.read_csv("data.csv")
weights = [1, 1, 1, 2]
impacts = ['+', '+', '-', '+']
result = topsis(data, weights, impacts)
print(result[['Model', 'Topsis Score', 'Rank']])
Part III — REST API + Web Interface
Run backend locally
pip install flask flask-cors pandas numpy
python app.py
# → http://localhost:5000
Open web interface
Just open index.html in any browser — no build step needed.
API — POST /topsis
curl -X POST http://localhost:5000/topsis \
-F "file=@data.csv" \
-F "weights=1,1,1,2" \
-F "impacts=+,+,-,+" \
-F "email=you@example.com" \
--output result.csv
Project Structure
topsis-project/
├── topsis/
│ ├── __init__.py # Package init
│ ├── core.py # TOPSIS algorithm (NumPy/Pandas)
│ └── cli.py # Command-line entry point
├── app.py # Flask REST API
├── index.html # Web interface
├── data.csv # Sample input
├── setup.py # PyPI config
├── requirements.txt
└── README.md
Skills Demonstrated
- Algorithm implementation from academic paper → production code
- Python package development and PyPI publishing
- REST API design with Flask
- Vectorized computation with NumPy
- End-to-end delivery: CLI → package → API → UI
Dependencies
pandas>=1.3.0
numpy>=1.21.0
flask>=2.0.0
flask-cors>=3.0.0
License
MIT
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file topsis_niyati_102303356-1.0.1.tar.gz.
File metadata
- Download URL: topsis_niyati_102303356-1.0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f08b0b9941ff4db73bc9a97bb9f77aa3723ccde6abe0e5ad9c1a191f672f30b0
|
|
| MD5 |
b03d096a953a066f1f93657d057f79cf
|
|
| BLAKE2b-256 |
249d8febd3e09eb2de9e3a11509aaae316153f623efa867fc1c98df518d991c6
|
File details
Details for the file topsis_niyati_102303356-1.0.1-py3-none-any.whl.
File metadata
- Download URL: topsis_niyati_102303356-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6ccaf4d23dcc78d9eec2b18a45c446934a4c97169bc7442b1d7d1e288dda27a
|
|
| MD5 |
3cff2daab7da4554f3c59b7b2337c6b5
|
|
| BLAKE2b-256 |
39e362080f2868373110ce0d6163bb87f2cc37630def9e5c2bf6f567297302e6
|