TOPSIS decision method Python package
Project description
TOPSIS Implementation - Sachin Goyal
A complete TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) implementation in Python with both CLI and Web Service interfaces.
๐ Quick Start
๐ฆ Install from PyPI
pip install topsis-sachingoyal-102303557==1.0.0
๐ Try the Web Interface
Access the live web service at:
https://topsis-sachin-goyal-102303557.vercel.app/
Upload your CSV, enter weights and impacts, and receive results via email!
๐ Project Structure
Topsis_SachinGoyal_102303557/
โ
โโโ topsis/ # Python package
โ โโโ __init__.py
โ โโโ topsis.py # Core TOPSIS implementation
โ
โโโ templates/ # Web frontend
โ โโโ index.html # Beautiful web UI
โ
โโโ uploads/ # Temporary file storage (created automatically)
โ
โโโ main.py # FastAPI backend server
โโโ data.csv # Sample input data
โโโ setup.py # Package setup configuration
โโโ requirements.txt # Python dependencies
โโโ sample.env # Environment variables template
โโโ README.md # This file
๐ Requirements
- Python 3.6+
- Dependencies: pandas, numpy, fastapi, mailjet-rest, python-dotenv
Install all dependencies:
pip install -r requirements.txt
๐ง Setup for Local Development
1. Clone the Repository
git clone <https://github.com/SachinGoyal94/Topsis_SachinGoyal_102303557>
cd Topsis_SachinGoyal_102303557
2. Install Dependencies
pip install -r requirements.txt
3. Configure Environment Variables
Create a .env file in the project root with the following:
SENDER_NAME=Your Name
SENDER_EMAIL=your-verified-email@example.com
MJ_APIKEY_PUBLIC=your-mailjet-public-key
MJ_APIKEY_PRIVATE=your-mailjet-private-key
Note: A
sample.envfile is provided as a template. Copy it to.envand fill in your credentials.
Required Variables:
SENDER_NAME- Your name or service nameSENDER_EMAIL- Verified sender email in MailjetMJ_APIKEY_PUBLIC- Your Mailjet API public keyMJ_APIKEY_PRIVATE- Your Mailjet API secret key
4. Run the Backend Server
uvicorn main:app --reload
The API will be available at http://127.0.0.1:8000
5. Open the Frontend
Navigate to http://127.0.0.1:8000 in your browser (if serving static files) or open templates/index.html directly.
๐ป CLI Usage
Command Syntax
python -m topsis.topsis <InputFile> "<Weights>" "<Impacts>" <OutputFile>
Arguments
| Argument | Description | Example |
|---|---|---|
InputFile |
Path to input CSV file | data.csv |
Weights |
Comma-separated numeric weights | "1,1,1,1,2" |
Impacts |
Comma-separated + or - | "+,+,-,+,+" |
OutputFile |
Path for output CSV | result.csv |
Example
python -m topsis.topsis data.csv "1,1,1,1,2" "+,+,+,-,+" result.csv
Output: Creates result.csv with two additional columns:
Topsis Score(higher is better)Rank(1 = best)
๐ Input CSV Format
Your CSV must have:
- First column: Identifier (e.g., product name, model ID)
- Remaining columns: Numeric criteria values
Example Input
Name,Cost,Performance,Reliability,Efficiency
ProductA,250,8,9,7
ProductB,200,7,8,9
ProductC,300,9,7,8
Example Output
Name,Cost,Performance,Reliability,Efficiency,Topsis Score,Rank
ProductA,250,8,9,7,0.534,2
ProductB,200,7,8,9,0.628,1
ProductC,300,9,7,8,0.421,3
๐ Web Service Usage
- Visit: https://topsis-sachin-goyal-102303557.vercel.app/
- Upload your CSV file
- Enter weights (e.g.,
1,1,1) - Enter impacts (e.g.,
+,+,-) - Enter your email address
- Submit and receive results via email
โ ๏ธ Common Errors
| Error | Cause | Solution |
|---|---|---|
Input file not found |
File path is incorrect | Check file path and try again |
Invalid email format |
Email is malformed | Use valid email format |
Weights and impacts count mismatch |
Different number of weights vs impacts | Ensure equal counts |
Impacts must be + or - |
Invalid impact symbol | Use only + or - |
Weights must be numeric |
Non-numeric weight | Use only numbers |
All columns must be numeric |
Non-numeric criteria values | Ensure all criteria are numbers |
๐ How TOPSIS Works
- Normalize the decision matrix using Euclidean normalization
- Weight the normalized matrix
- Identify ideal best and worst solutions
- Calculate Euclidean distances from ideal solutions
- Compute similarity score:
S = D- / (D+ + D-) - Rank alternatives by score (higher is better)
๐ ๏ธ Technology Stack
- Backend: FastAPI (Python)
- Frontend: HTML, CSS, JavaScript
- Email Service: Mailjet REST API
- Package Management: PyPI
- Deployment:
- Frontend: Vercel
- Backend: Render
๐ค Author
Sachin Goyal
๐ Links
- PyPI Package: topsis-sachingoyal-102303557
- Web App: https://topsis-sachin-goyal-102303557.vercel.app/
- GitHub: https://github.com/SachinGoyal94/Topsis_SachinGoyal_102303557
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
File details
Details for the file topsis_sachin_102303557-1.0.0.tar.gz.
File metadata
- Download URL: topsis_sachin_102303557-1.0.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
951e64f2b8f96a51ecc8c27c683522a1610fd1945940c17860ba81557ef65da9
|
|
| MD5 |
1009a2574236df9055f37b0143104023
|
|
| BLAKE2b-256 |
b23c1445a25eeadfb78d6623d62fd1c0bc676b51e7553fbccbd9a10e26dab08b
|