topsis-anshul-102303930 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.
File without changes
@@ -0,0 +1,78 @@
1
+ import sys
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+ def main():
6
+ if len(sys.argv) != 5:
7
+ print("Usage: python topsis.py <InputDataFile> <Weights> <Impacts> <OutputResultFileName>")
8
+ sys.exit(1)
9
+
10
+ input_file = sys.argv[1]
11
+ weights = sys.argv[2]
12
+ impacts = sys.argv[3]
13
+ output_file = sys.argv[4]
14
+
15
+ try:
16
+ data = pd.read_csv(input_file)
17
+ except FileNotFoundError:
18
+ print("Error: Input file not found")
19
+ sys.exit(1)
20
+
21
+ if data.shape[1] < 3:
22
+ print("Error: Input file must contain at least three columns")
23
+ sys.exit(1)
24
+
25
+ weights = weights.split(",")
26
+ impacts = impacts.split(",")
27
+
28
+ num_criteria = data.shape[1] - 1
29
+
30
+ if len(weights) != num_criteria or len(impacts) != num_criteria:# Yahan per hum no. columns ko match kar rhe hain with no. of weights and impacts provided
31
+ print("Error: Number of weights and impacts must match number of criteria")
32
+ sys.exit(1)
33
+
34
+ for impact in impacts:
35
+ if impact not in ['+', '-']:
36
+ print("Error: Impacts must be either '+' or '-'")
37
+ sys.exit(1)
38
+ try:
39
+ data.iloc[:, 1:] = data.iloc[:, 1:].astype(float)
40
+ except ValueError:
41
+ print("Error: Criteria columns must contain numeric values only")
42
+ sys.exit(1)
43
+ ### Validations end here
44
+ weights = np.array(weights, dtype=float)
45
+ weights = weights / np.sum(weights) # Normazing the Weights
46
+ criteria = data.iloc[:, 1:].values
47
+ norm = np.sqrt((criteria ** 2).sum(axis=0))# normalizing the Values in the matrix
48
+ normalized_matrix = criteria / norm
49
+ weighted_matrix = normalized_matrix * weights
50
+
51
+ ideal_best = []
52
+ ideal_worst = []
53
+
54
+ for i in range(len(impacts)):
55
+ if impacts[i] == '+':
56
+ ideal_best.append(weighted_matrix[:, i].max())
57
+ ideal_worst.append(weighted_matrix[:, i].min())
58
+ else:
59
+ ideal_best.append(weighted_matrix[:, i].min())
60
+ ideal_worst.append(weighted_matrix[:, i].max())
61
+
62
+ ideal_best = np.array(ideal_best)
63
+ ideal_worst = np.array(ideal_worst)
64
+
65
+ dist_best = np.sqrt(((weighted_matrix - ideal_best) ** 2).sum(axis=1))
66
+ dist_worst = np.sqrt(((weighted_matrix - ideal_worst) ** 2).sum(axis=1))
67
+
68
+
69
+ topsis_score = dist_worst / (dist_best + dist_worst)
70
+ data["Topsis Score"] = topsis_score.round(6)
71
+ data["Rank"] = data["Topsis Score"].rank(ascending=False, method='dense').astype(int)
72
+
73
+ data.to_csv(output_file, index=False)
74
+ print("TOPSIS analysis completed successfully.")
75
+
76
+
77
+ if __name__ == "__main__":
78
+ main()
@@ -0,0 +1,15 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anshul Kaushal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.1
2
+ Name: topsis-anshul-102303930
3
+ Version: 1.0.0
4
+ Summary: A Python package for TOPSIS multi-criteria decision making
5
+ Author: Anshul Kaushal
6
+ Author-email: anshulkaushal27@gmail.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: pandas
14
+ Requires-Dist: numpy
15
+
16
+ \# Topsis-Anshul-102303930
17
+
18
+
19
+
20
+ \## 📌 Description
21
+
22
+ This package implements the TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) method.
23
+
24
+ TOPSIS is a multi-criteria decision-making approach used to rank alternatives based on their distance from
25
+
26
+ an ideal best and an ideal worst solution.
27
+
28
+
29
+
30
+ ---
31
+
32
+
33
+
34
+ \## ⚙️ Installation
35
+
36
+ Install the package using pip:
37
+
38
+
39
+
40
+ ```bash
41
+
42
+ pip install Topsis-Anshul-102303930
43
+
44
+
45
+
@@ -0,0 +1,8 @@
1
+ topsis_anshul/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ topsis_anshul/topsis.py,sha256=nxT4WXz7Z2KU17EOpviNfBPE4XdB794wSyT0seMzd_k,2556
3
+ topsis_anshul_102303930-1.0.0.dist-info/LICENSE,sha256=XFA2fzQCLy41yBxlaoLoMFCr_mFFPsUqtx58outGwfo,689
4
+ topsis_anshul_102303930-1.0.0.dist-info/METADATA,sha256=isv0Uix1WPRzgMmWhywtwRx1fVy2grhXMtwba39LbbA,947
5
+ topsis_anshul_102303930-1.0.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
6
+ topsis_anshul_102303930-1.0.0.dist-info/entry_points.txt,sha256=fM1Se7TB5H5DyOFpENDatsDEMD1odgCE4QXiT38xW_g,53
7
+ topsis_anshul_102303930-1.0.0.dist-info/top_level.txt,sha256=xnQI0g8RBd7KKV__q4kvGFvD4LUGWRp_EQ3TWz5BV_w,14
8
+ topsis_anshul_102303930-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ topsis = topsis_anshul.topsis:main
@@ -0,0 +1 @@
1
+ topsis_anshul