topsis-pranshu-102313009 1.0.1__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.
File without changes
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: topsis-pranshu-102313009
3
+ Version: 1.0.1
4
+ Summary: TOPSIS command-line tool
5
+ Author: Pranshu Goel
6
+ Author-email: your@email.com
7
+ License-File: LICENSE
8
+ Requires-Dist: pandas
9
+ Requires-Dist: numpy
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: license-file
13
+ Dynamic: requires-dist
14
+ Dynamic: summary
File without changes
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="topsis-pranshu-102313009",
5
+ version="1.0.1",
6
+ author="Pranshu Goel",
7
+ author_email="your@email.com",
8
+ description="TOPSIS command-line tool",
9
+ packages=find_packages(),
10
+ install_requires=["pandas", "numpy"],
11
+ entry_points={
12
+ "console_scripts": [
13
+ "topsis=topsis_pranshu.topsis:main"
14
+ ]
15
+ },
16
+ )
@@ -0,0 +1,71 @@
1
+ import sys
2
+ import pandas as pd
3
+ import numpy as np
4
+ import os
5
+
6
+ def error(msg):
7
+ print(f"Error: {msg}")
8
+ sys.exit(1)
9
+
10
+ def main():
11
+ if len(sys.argv) != 5:
12
+ error("Usage: topsis <InputFile> <Weights> <Impacts> <OutputFile>")
13
+
14
+ input_file, weights, impacts, output_file = sys.argv[1:]
15
+
16
+ if not os.path.exists(input_file):
17
+ error("Input file not found")
18
+
19
+ try:
20
+ df = pd.read_csv(input_file, encoding="utf-8")
21
+ except UnicodeDecodeError:
22
+ df = pd.read_csv(input_file, encoding="latin1")
23
+
24
+ if df.shape[1] < 3:
25
+ error("File must contain at least 3 columns")
26
+
27
+ data = df.iloc[:, 1:]
28
+
29
+ try:
30
+ data = data.astype(float)
31
+ except:
32
+ error("Non-numeric values found")
33
+
34
+ weights = list(map(float, weights.split(",")))
35
+ impacts = impacts.split(",")
36
+
37
+ if len(weights) != len(impacts) or len(weights) != data.shape[1]:
38
+ error("Weights, impacts and criteria count mismatch")
39
+
40
+ if not all(i in ['+', '-'] for i in impacts):
41
+ error("Impacts must be + or -")
42
+
43
+ norm = data / np.sqrt((data ** 2).sum())
44
+ weighted = norm * weights
45
+
46
+ best = []
47
+ worst = []
48
+
49
+ for i, impact in enumerate(impacts):
50
+ if impact == '+':
51
+ best.append(weighted.iloc[:, i].max())
52
+ worst.append(weighted.iloc[:, i].min())
53
+ else:
54
+ best.append(weighted.iloc[:, i].min())
55
+ worst.append(weighted.iloc[:, i].max())
56
+
57
+ best = np.array(best)
58
+ worst = np.array(worst)
59
+
60
+ d_pos = np.sqrt(((weighted - best) ** 2).sum(axis=1))
61
+ d_neg = np.sqrt(((weighted - worst) ** 2).sum(axis=1))
62
+
63
+ score = d_neg / (d_pos + d_neg)
64
+ df["Topsis Score"] = score
65
+ df["Rank"] = score.rank(ascending=False).astype(int)
66
+
67
+ df.to_csv(output_file, index=False)
68
+ print("TOPSIS completed")
69
+
70
+ if __name__ == "__main__":
71
+ main()
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: topsis-pranshu-102313009
3
+ Version: 1.0.1
4
+ Summary: TOPSIS command-line tool
5
+ Author: Pranshu Goel
6
+ Author-email: your@email.com
7
+ License-File: LICENSE
8
+ Requires-Dist: pandas
9
+ Requires-Dist: numpy
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: license-file
13
+ Dynamic: requires-dist
14
+ Dynamic: summary
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ topsis_pranshu/__init__.py
5
+ topsis_pranshu/topsis.py
6
+ topsis_pranshu_102313009.egg-info/PKG-INFO
7
+ topsis_pranshu_102313009.egg-info/SOURCES.txt
8
+ topsis_pranshu_102313009.egg-info/dependency_links.txt
9
+ topsis_pranshu_102313009.egg-info/entry_points.txt
10
+ topsis_pranshu_102313009.egg-info/requires.txt
11
+ topsis_pranshu_102313009.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ topsis = topsis_pranshu.topsis:main