Topsis-Abhishek-Kansal-102303808 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topsis_abhishek_kansal_102303808-1.0.0/PKG-INFO +40 -0
- topsis_abhishek_kansal_102303808-1.0.0/README.md +30 -0
- topsis_abhishek_kansal_102303808-1.0.0/pyproject.toml +17 -0
- topsis_abhishek_kansal_102303808-1.0.0/setup.cfg +4 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808/__init__.py +0 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808/topsis.py +141 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/PKG-INFO +40 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/SOURCES.txt +10 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/dependency_links.txt +1 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/entry_points.txt +2 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/requires.txt +2 -0
- topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Abhishek-Kansal-102303808
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Python package for TOPSIS decision making
|
|
5
|
+
Author-email: Abhishek Kansal <akansal_be23@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: pandas
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
|
|
11
|
+
# Topsis-Abhishek-Kansal-102303808
|
|
12
|
+
|
|
13
|
+
This project implements TOPSIS (Technique for Order Preference by Similarity to Ideal Solution).
|
|
14
|
+
It is used to rank alternatives based on multiple criteria.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Use pip to install the package:
|
|
19
|
+
|
|
20
|
+
pip install Topsis-Abhishek-Kansal-102303808
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
Run the program using:
|
|
25
|
+
|
|
26
|
+
topsis-abhishek input.csv "1,1,1" "+,+,-" result.csv
|
|
27
|
+
|
|
28
|
+
## Input Format
|
|
29
|
+
|
|
30
|
+
The input file must contain alternative names in the first column.
|
|
31
|
+
All other columns must be numeric.
|
|
32
|
+
|
|
33
|
+
## Output
|
|
34
|
+
|
|
35
|
+
The output file will contain TOPSIS score and rank.
|
|
36
|
+
|
|
37
|
+
## Author
|
|
38
|
+
|
|
39
|
+
Abhishek Kansal
|
|
40
|
+
Roll Number: 102303808
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Topsis-Abhishek-Kansal-102303808
|
|
2
|
+
|
|
3
|
+
This project implements TOPSIS (Technique for Order Preference by Similarity to Ideal Solution).
|
|
4
|
+
It is used to rank alternatives based on multiple criteria.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Use pip to install the package:
|
|
9
|
+
|
|
10
|
+
pip install Topsis-Abhishek-Kansal-102303808
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
Run the program using:
|
|
15
|
+
|
|
16
|
+
topsis-abhishek input.csv "1,1,1" "+,+,-" result.csv
|
|
17
|
+
|
|
18
|
+
## Input Format
|
|
19
|
+
|
|
20
|
+
The input file must contain alternative names in the first column.
|
|
21
|
+
All other columns must be numeric.
|
|
22
|
+
|
|
23
|
+
## Output
|
|
24
|
+
|
|
25
|
+
The output file will contain TOPSIS score and rank.
|
|
26
|
+
|
|
27
|
+
## Author
|
|
28
|
+
|
|
29
|
+
Abhishek Kansal
|
|
30
|
+
Roll Number: 102303808
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Topsis-Abhishek-Kansal-102303808"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "A Python package for TOPSIS decision making"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name="Abhishek Kansal", email="akansal_be23@gmail.com" }
|
|
12
|
+
]
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
dependencies = ["pandas", "numpy"]
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
topsis-abhishek = "Topsis_Abhishek_Kansal_102303808.topsis:main"
|
|
File without changes
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
def error(msg):
|
|
7
|
+
print("Error:", msg)
|
|
8
|
+
sys.exit(1)
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
# ===============================
|
|
12
|
+
# CHECK ARGUMENT COUNT
|
|
13
|
+
# ===============================
|
|
14
|
+
if len(sys.argv) != 5:
|
|
15
|
+
error("Usage: python topsis.py <InputDataFile> <Weights> <Impacts> <OutputFile>")
|
|
16
|
+
|
|
17
|
+
input_file = sys.argv[1]
|
|
18
|
+
weights = sys.argv[2]
|
|
19
|
+
impacts = sys.argv[3]
|
|
20
|
+
output_file = sys.argv[4]
|
|
21
|
+
|
|
22
|
+
# ===============================
|
|
23
|
+
# CHECK FILE EXISTS
|
|
24
|
+
# ===============================
|
|
25
|
+
if not os.path.exists(input_file):
|
|
26
|
+
error("Input file not found!")
|
|
27
|
+
|
|
28
|
+
# ===============================
|
|
29
|
+
# LOAD FILE (CSV or XLSX)
|
|
30
|
+
# ===============================
|
|
31
|
+
try:
|
|
32
|
+
if input_file.endswith(".csv"):
|
|
33
|
+
df = pd.read_csv(input_file)
|
|
34
|
+
elif input_file.endswith(".xlsx"):
|
|
35
|
+
df = pd.read_excel(input_file)
|
|
36
|
+
else:
|
|
37
|
+
error("Input file must be .csv or .xlsx")
|
|
38
|
+
except:
|
|
39
|
+
error("Unable to read input file!")
|
|
40
|
+
|
|
41
|
+
# ===============================
|
|
42
|
+
# CHECK MIN COLUMNS
|
|
43
|
+
# ===============================
|
|
44
|
+
if df.shape[1] < 3:
|
|
45
|
+
error("Input file must contain at least 3 columns!")
|
|
46
|
+
|
|
47
|
+
# ===============================
|
|
48
|
+
# CHECK NUMERIC DATA (2nd to last col)
|
|
49
|
+
# ===============================
|
|
50
|
+
data = df.iloc[:, 1:]
|
|
51
|
+
|
|
52
|
+
for col in data.columns:
|
|
53
|
+
if not pd.api.types.is_numeric_dtype(data[col]):
|
|
54
|
+
error("From 2nd to last column, all values must be numeric!")
|
|
55
|
+
|
|
56
|
+
# ===============================
|
|
57
|
+
# PARSE WEIGHTS & IMPACTS
|
|
58
|
+
# ===============================
|
|
59
|
+
weights = weights.split(",")
|
|
60
|
+
impacts = impacts.split(",")
|
|
61
|
+
|
|
62
|
+
if len(weights) != data.shape[1]:
|
|
63
|
+
error("Number of weights must match number of criteria columns!")
|
|
64
|
+
|
|
65
|
+
if len(impacts) != data.shape[1]:
|
|
66
|
+
error("Number of impacts must match number of criteria columns!")
|
|
67
|
+
|
|
68
|
+
# Convert weights to float
|
|
69
|
+
try:
|
|
70
|
+
weights = np.array([float(w) for w in weights])
|
|
71
|
+
except:
|
|
72
|
+
error("Weights must be numeric!")
|
|
73
|
+
|
|
74
|
+
# Validate impacts
|
|
75
|
+
for imp in impacts:
|
|
76
|
+
if imp not in ['+', '-']:
|
|
77
|
+
error("Impacts must be either + or - only!")
|
|
78
|
+
|
|
79
|
+
impacts = np.array(impacts)
|
|
80
|
+
|
|
81
|
+
# ===============================
|
|
82
|
+
# STEP 1: NORMALIZATION
|
|
83
|
+
# ===============================
|
|
84
|
+
norm = np.sqrt((data ** 2).sum())
|
|
85
|
+
norm_data = data / norm
|
|
86
|
+
|
|
87
|
+
# ===============================
|
|
88
|
+
# STEP 2: WEIGHTED NORMALIZATION
|
|
89
|
+
# ===============================
|
|
90
|
+
weighted_data = norm_data * weights
|
|
91
|
+
|
|
92
|
+
# ===============================
|
|
93
|
+
# STEP 3: IDEAL BEST & WORST
|
|
94
|
+
# ===============================
|
|
95
|
+
ideal_best = []
|
|
96
|
+
ideal_worst = []
|
|
97
|
+
|
|
98
|
+
for i in range(len(impacts)):
|
|
99
|
+
if impacts[i] == '+':
|
|
100
|
+
ideal_best.append(weighted_data.iloc[:, i].max())
|
|
101
|
+
ideal_worst.append(weighted_data.iloc[:, i].min())
|
|
102
|
+
else:
|
|
103
|
+
ideal_best.append(weighted_data.iloc[:, i].min())
|
|
104
|
+
ideal_worst.append(weighted_data.iloc[:, i].max())
|
|
105
|
+
|
|
106
|
+
ideal_best = np.array(ideal_best)
|
|
107
|
+
ideal_worst = np.array(ideal_worst)
|
|
108
|
+
|
|
109
|
+
# ===============================
|
|
110
|
+
# STEP 4: DISTANCE FROM IDEAL BEST & WORST
|
|
111
|
+
# ===============================
|
|
112
|
+
dist_best = np.sqrt(((weighted_data - ideal_best) ** 2).sum(axis=1))
|
|
113
|
+
dist_worst = np.sqrt(((weighted_data - ideal_worst) ** 2).sum(axis=1))
|
|
114
|
+
|
|
115
|
+
# ===============================
|
|
116
|
+
# STEP 5: TOPSIS SCORE
|
|
117
|
+
# ===============================
|
|
118
|
+
topsis_score = dist_worst / (dist_best + dist_worst)
|
|
119
|
+
|
|
120
|
+
# ===============================
|
|
121
|
+
# STEP 6: RANKING
|
|
122
|
+
# ===============================
|
|
123
|
+
df["Topsis Score"] = topsis_score
|
|
124
|
+
df["Rank"] = df["Topsis Score"].rank(ascending=False, method="dense").astype(int)
|
|
125
|
+
|
|
126
|
+
# ===============================
|
|
127
|
+
# SAVE OUTPUT
|
|
128
|
+
# ===============================
|
|
129
|
+
if output_file.endswith(".xlsx"):
|
|
130
|
+
df.to_excel(output_file, index=False)
|
|
131
|
+
else:
|
|
132
|
+
df.to_csv(output_file, index=False)
|
|
133
|
+
|
|
134
|
+
print("✅ TOPSIS analysis completed successfully!")
|
|
135
|
+
print("📁 Output saved to:", output_file)
|
|
136
|
+
|
|
137
|
+
# ===============================
|
|
138
|
+
# MAIN
|
|
139
|
+
# ===============================
|
|
140
|
+
if __name__ == "__main__":
|
|
141
|
+
main()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Abhishek-Kansal-102303808
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Python package for TOPSIS decision making
|
|
5
|
+
Author-email: Abhishek Kansal <akansal_be23@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: pandas
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
|
|
11
|
+
# Topsis-Abhishek-Kansal-102303808
|
|
12
|
+
|
|
13
|
+
This project implements TOPSIS (Technique for Order Preference by Similarity to Ideal Solution).
|
|
14
|
+
It is used to rank alternatives based on multiple criteria.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Use pip to install the package:
|
|
19
|
+
|
|
20
|
+
pip install Topsis-Abhishek-Kansal-102303808
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
Run the program using:
|
|
25
|
+
|
|
26
|
+
topsis-abhishek input.csv "1,1,1" "+,+,-" result.csv
|
|
27
|
+
|
|
28
|
+
## Input Format
|
|
29
|
+
|
|
30
|
+
The input file must contain alternative names in the first column.
|
|
31
|
+
All other columns must be numeric.
|
|
32
|
+
|
|
33
|
+
## Output
|
|
34
|
+
|
|
35
|
+
The output file will contain TOPSIS score and rank.
|
|
36
|
+
|
|
37
|
+
## Author
|
|
38
|
+
|
|
39
|
+
Abhishek Kansal
|
|
40
|
+
Roll Number: 102303808
|
topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/Topsis_Abhishek_Kansal_102303808/__init__.py
|
|
4
|
+
src/Topsis_Abhishek_Kansal_102303808/topsis.py
|
|
5
|
+
src/Topsis_Abhishek_Kansal_102303808.egg-info/PKG-INFO
|
|
6
|
+
src/Topsis_Abhishek_Kansal_102303808.egg-info/SOURCES.txt
|
|
7
|
+
src/Topsis_Abhishek_Kansal_102303808.egg-info/dependency_links.txt
|
|
8
|
+
src/Topsis_Abhishek_Kansal_102303808.egg-info/entry_points.txt
|
|
9
|
+
src/Topsis_Abhishek_Kansal_102303808.egg-info/requires.txt
|
|
10
|
+
src/Topsis_Abhishek_Kansal_102303808.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
topsis_abhishek_kansal_102303808-1.0.0/src/Topsis_Abhishek_Kansal_102303808.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Topsis_Abhishek_Kansal_102303808
|