topsis-keshav-102303520 1.0.0__py3-none-any.whl
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_keshav_102303520/__init__.py +0 -0
- topsis_keshav_102303520/topsis.py +69 -0
- topsis_keshav_102303520-1.0.0.dist-info/METADATA +12 -0
- topsis_keshav_102303520-1.0.0.dist-info/RECORD +7 -0
- topsis_keshav_102303520-1.0.0.dist-info/WHEEL +5 -0
- topsis_keshav_102303520-1.0.0.dist-info/entry_points.txt +2 -0
- topsis_keshav_102303520-1.0.0.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
def error(msg):
|
|
7
|
+
print("Error:", msg)
|
|
8
|
+
sys.exit(1)
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
if len(sys.argv) != 5:
|
|
12
|
+
error("Usage: topsis <InputDataFile> <Weights> <Impacts> <OutputFile>")
|
|
13
|
+
|
|
14
|
+
input_file = sys.argv[1]
|
|
15
|
+
weights = sys.argv[2]
|
|
16
|
+
impacts = sys.argv[3]
|
|
17
|
+
output_file = sys.argv[4]
|
|
18
|
+
|
|
19
|
+
if not os.path.isfile(input_file):
|
|
20
|
+
error("Input file does not exist")
|
|
21
|
+
|
|
22
|
+
df = pd.read_csv(input_file)
|
|
23
|
+
|
|
24
|
+
if df.shape[1] < 3:
|
|
25
|
+
error("Input file must contain at least 3 columns")
|
|
26
|
+
|
|
27
|
+
data = df.iloc[:, 1:]
|
|
28
|
+
|
|
29
|
+
if not all(data.map(np.isreal).all()):
|
|
30
|
+
error("Columns from 2nd to last must be numeric")
|
|
31
|
+
|
|
32
|
+
weights = list(map(float, weights.split(',')))
|
|
33
|
+
impacts = impacts.split(',')
|
|
34
|
+
|
|
35
|
+
if len(weights) != data.shape[1]:
|
|
36
|
+
error("Number of weights must match number of criteria")
|
|
37
|
+
|
|
38
|
+
if len(impacts) != data.shape[1]:
|
|
39
|
+
error("Number of impacts must match number of criteria")
|
|
40
|
+
|
|
41
|
+
for i in impacts:
|
|
42
|
+
if i not in ['+', '-']:
|
|
43
|
+
error("Impacts must be either + or -")
|
|
44
|
+
|
|
45
|
+
norm = np.sqrt((data ** 2).sum())
|
|
46
|
+
normalized = data / norm
|
|
47
|
+
weighted = normalized * weights
|
|
48
|
+
|
|
49
|
+
ideal_best = []
|
|
50
|
+
ideal_worst = []
|
|
51
|
+
|
|
52
|
+
for i in range(len(impacts)):
|
|
53
|
+
if impacts[i] == '+':
|
|
54
|
+
ideal_best.append(weighted.iloc[:, i].max())
|
|
55
|
+
ideal_worst.append(weighted.iloc[:, i].min())
|
|
56
|
+
else:
|
|
57
|
+
ideal_best.append(weighted.iloc[:, i].min())
|
|
58
|
+
ideal_worst.append(weighted.iloc[:, i].max())
|
|
59
|
+
|
|
60
|
+
dist_best = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
|
|
61
|
+
dist_worst = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
|
|
62
|
+
|
|
63
|
+
score = dist_worst / (dist_best + dist_worst)
|
|
64
|
+
|
|
65
|
+
df["Topsis Score"] = score
|
|
66
|
+
df["Rank"] = score.rank(ascending=False).astype(int)
|
|
67
|
+
|
|
68
|
+
df.to_csv(output_file, index=False)
|
|
69
|
+
print("TOPSIS analysis completed successfully")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: topsis-keshav-102303520
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: TOPSIS decision making package
|
|
5
|
+
Author: Keshav Sharma
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
Requires-Dist: pandas
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: requires-dist
|
|
11
|
+
Dynamic: requires-python
|
|
12
|
+
Dynamic: summary
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
topsis_keshav_102303520/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
topsis_keshav_102303520/topsis.py,sha256=TRRSvMJfRUUPJCczi6N2Oh03h9t690RTwuByA0kDsjA,1976
|
|
3
|
+
topsis_keshav_102303520-1.0.0.dist-info/METADATA,sha256=UX1Z4a9E19ow2a_xbk4WQCz-AMIIhnbnWGcJvTjHlLw,288
|
|
4
|
+
topsis_keshav_102303520-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
+
topsis_keshav_102303520-1.0.0.dist-info/entry_points.txt,sha256=vMgTVEzgrKhN9JYcKMZ21XP6r9MthuSlt3Im8coQyuY,63
|
|
6
|
+
topsis_keshav_102303520-1.0.0.dist-info/top_level.txt,sha256=nNY4NE2Yn78yxVf7Fi2XmZvbrYQmTVxsGk86xhabo40,24
|
|
7
|
+
topsis_keshav_102303520-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
topsis_keshav_102303520
|