Topsis-Anahat-102313058 1.0.1__tar.gz → 1.0.3__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_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/PKG-INFO +1 -1
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/Topsis_Anahat_102313058.egg-info/PKG-INFO +1 -1
- topsis_anahat_102313058-1.0.3/Topsis_Anahat_102313058.egg-info/entry_points.txt +2 -0
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/setup.py +5 -5
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/topsis_anahat_102313058/topsis.py +15 -24
- topsis_anahat_102313058-1.0.1/Topsis_Anahat_102313058.egg-info/entry_points.txt +0 -2
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/README.md +0 -0
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/Topsis_Anahat_102313058.egg-info/SOURCES.txt +0 -0
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/Topsis_Anahat_102313058.egg-info/dependency_links.txt +0 -0
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/Topsis_Anahat_102313058.egg-info/requires.txt +0 -0
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/Topsis_Anahat_102313058.egg-info/top_level.txt +0 -0
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/setup.cfg +0 -0
- {topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/topsis_anahat_102313058/__init__.py +0 -0
|
@@ -2,14 +2,14 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="Topsis-Anahat-102313058",
|
|
5
|
-
version="1.0.
|
|
5
|
+
version="1.0.3",
|
|
6
6
|
author="Anahat",
|
|
7
7
|
description="TOPSIS implementation using Python",
|
|
8
8
|
packages=find_packages(),
|
|
9
9
|
install_requires=["pandas", "numpy"],
|
|
10
10
|
entry_points={
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
"console_scripts": [
|
|
12
|
+
"topsis=topsis_anahat_102313058.topsis:cli"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
15
|
)
|
{topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/topsis_anahat_102313058/topsis.py
RENAMED
|
@@ -6,18 +6,9 @@ def error(msg):
|
|
|
6
6
|
print(f"Error: {msg}")
|
|
7
7
|
sys.exit(1)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
error("Incorrect number of parameters.\nUsage: python topsis.py <InputFile> <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
|
-
#Message for wrong inputs
|
|
20
|
-
#File Handling
|
|
9
|
+
# ---------------- CORE LOGIC ----------------
|
|
10
|
+
def topsis(input_file, weights, impacts, output_file):
|
|
11
|
+
|
|
21
12
|
try:
|
|
22
13
|
data = pd.read_csv(input_file)
|
|
23
14
|
except FileNotFoundError:
|
|
@@ -26,13 +17,11 @@ def main():
|
|
|
26
17
|
if data.shape[1] < 3:
|
|
27
18
|
error("Input file must contain three or more columns.")
|
|
28
19
|
|
|
29
|
-
#Numeric Validation
|
|
30
20
|
try:
|
|
31
21
|
matrix = data.iloc[:, 1:].astype(float)
|
|
32
22
|
except ValueError:
|
|
33
23
|
error("From 2nd to last columns must contain numeric values only.")
|
|
34
24
|
|
|
35
|
-
#Weights & Impacts
|
|
36
25
|
try:
|
|
37
26
|
weights = list(map(float, weights.split(',')))
|
|
38
27
|
except:
|
|
@@ -47,14 +36,9 @@ def main():
|
|
|
47
36
|
if i not in ['+', '-']:
|
|
48
37
|
error("Impacts must be either '+' or '-'.")
|
|
49
38
|
|
|
50
|
-
# TOPSIS Steps
|
|
51
|
-
# Step 1: Normalize
|
|
52
39
|
norm = matrix / np.sqrt((matrix ** 2).sum())
|
|
53
|
-
|
|
54
|
-
# Step 2: Weighting
|
|
55
40
|
weighted = norm * weights
|
|
56
41
|
|
|
57
|
-
# Step 3: Ideal best & worst
|
|
58
42
|
ideal_best = []
|
|
59
43
|
ideal_worst = []
|
|
60
44
|
|
|
@@ -69,20 +53,27 @@ def main():
|
|
|
69
53
|
ideal_best = np.array(ideal_best)
|
|
70
54
|
ideal_worst = np.array(ideal_worst)
|
|
71
55
|
|
|
72
|
-
# Step 4: Distance
|
|
73
56
|
dist_best = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
|
|
74
57
|
dist_worst = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
|
|
75
58
|
|
|
76
|
-
# Step 5: Score
|
|
77
59
|
score = dist_worst / (dist_best + dist_worst)
|
|
78
60
|
|
|
79
|
-
# Step 6: Rank
|
|
80
61
|
data['Topsis Score'] = score
|
|
81
62
|
data['Rank'] = data['Topsis Score'].rank(ascending=False, method='dense').astype(int)
|
|
82
63
|
|
|
83
|
-
# Output
|
|
84
64
|
data.to_csv(output_file, index=False)
|
|
85
65
|
print(f"TOPSIS result saved to {output_file}")
|
|
86
66
|
|
|
67
|
+
# ---------------- CLI WRAPPER ----------------
|
|
68
|
+
def cli():
|
|
69
|
+
if len(sys.argv) != 5:
|
|
70
|
+
error(
|
|
71
|
+
"Incorrect number of parameters.\n"
|
|
72
|
+
"Usage: topsis <InputFile> <Weights> <Impacts> <OutputFile>"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
topsis(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
|
|
76
|
+
|
|
77
|
+
# ---------------- ENTRY ----------------
|
|
87
78
|
if __name__ == "__main__":
|
|
88
|
-
|
|
79
|
+
cli()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{topsis_anahat_102313058-1.0.1 → topsis_anahat_102313058-1.0.3}/topsis_anahat_102313058/__init__.py
RENAMED
|
File without changes
|