Topsis-Sameer-102303773 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sameer Rai
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, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-Sameer-102303773
3
+ Version: 1.0.0
4
+ Summary: A Python package implementing the TOPSIS method
5
+ Author: Sameer Rai
6
+ Author-email: your_email@gmail.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,14 @@
1
+ # 🚀 TOPSIS Python Package
2
+
3
+ This package implements **TOPSIS** (Technique for Order Preference by Similarity to Ideal Solution),
4
+ a 📊 multi-criteria decision-making technique used to rank alternatives based on their distance from ideal best and worst solutions.
5
+
6
+ ---
7
+
8
+ ## 📦 Installation
9
+
10
+ Install the package using `pip`:
11
+
12
+ ```bash
13
+ pip install Topsis-Sameer-102303773
14
+ ```
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-Sameer-102303773
3
+ Version: 1.0.0
4
+ Summary: A Python package implementing the TOPSIS method
5
+ Author: Sameer Rai
6
+ Author-email: your_email@gmail.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_Sameer_102303773.egg-info/PKG-INFO
5
+ Topsis_Sameer_102303773.egg-info/SOURCES.txt
6
+ Topsis_Sameer_102303773.egg-info/dependency_links.txt
7
+ Topsis_Sameer_102303773.egg-info/entry_points.txt
8
+ Topsis_Sameer_102303773.egg-info/requires.txt
9
+ Topsis_Sameer_102303773.egg-info/top_level.txt
10
+ topsis/__init__.py
11
+ topsis/topsis.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ topsis = topsis.topsis:main
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="Topsis-Sameer-102303773",
5
+ version="1.0.0",
6
+ author="Sameer Rai",
7
+ author_email="your_email@gmail.com",
8
+ description="A Python package implementing the TOPSIS method",
9
+ packages=find_packages(),
10
+ install_requires=[
11
+ "pandas",
12
+ "numpy"
13
+ ],
14
+ entry_points={
15
+ "console_scripts": [
16
+ "topsis=topsis.topsis:main"
17
+ ]
18
+ },
19
+ )
File without changes
@@ -0,0 +1,89 @@
1
+ import sys
2
+ import os
3
+ import pandas as pd
4
+ import numpy as np
5
+
6
+
7
+ def fail(msg):
8
+ print("Error:", msg)
9
+ sys.exit(1)
10
+
11
+
12
+ def main():
13
+ args = sys.argv
14
+
15
+ if len(args) != 5:
16
+ fail("Usage: topsis <input.csv> <weights> <impacts> <output.csv>")
17
+
18
+ inp = args[1]
19
+ wts = args[2]
20
+ imps = args[3]
21
+ out = args[4]
22
+
23
+ if not os.path.isfile(inp):
24
+ fail("Input file not found")
25
+
26
+ try:
27
+ df = pd.read_csv(inp)
28
+ except:
29
+ fail("Cannot read input file")
30
+
31
+ if df.shape[1] < 3:
32
+ fail("Input file must have at least 3 columns")
33
+
34
+ mat = df.iloc[:, 1:].values
35
+
36
+ if not np.issubdtype(mat.dtype, np.number):
37
+ fail("Columns must be numeric")
38
+
39
+ w = wts.split(',')
40
+ imp = imps.split(',')
41
+
42
+ n = mat.shape[1]
43
+
44
+ if len(w) != n or len(imp) != n:
45
+ fail("Weights, impacts and columns count mismatch")
46
+
47
+ try:
48
+ w = np.array(w, dtype=float)
49
+ except:
50
+ fail("Weights must be numbers")
51
+
52
+ for i in imp:
53
+ if i not in ['+', '-']:
54
+ fail("Impacts must be + or -")
55
+
56
+ den = np.sqrt((mat ** 2).sum(axis=0))
57
+ norm = mat / den
58
+
59
+ wmat = norm * w
60
+
61
+ best = []
62
+ worst = []
63
+
64
+ for i in range(n):
65
+ if imp[i] == '+':
66
+ best.append(wmat[:, i].max())
67
+ worst.append(wmat[:, i].min())
68
+ else:
69
+ best.append(wmat[:, i].min())
70
+ worst.append(wmat[:, i].max())
71
+
72
+ best = np.array(best)
73
+ worst = np.array(worst)
74
+
75
+ dpos = np.sqrt(((wmat - best) ** 2).sum(axis=1))
76
+ dneg = np.sqrt(((wmat - worst) ** 2).sum(axis=1))
77
+
78
+ score = dneg / (dpos + dneg)
79
+ rank = score.argsort()[::-1] + 1
80
+
81
+ df["Topsis Score"] = score
82
+ df["Rank"] = rank
83
+
84
+ df.to_csv(out, index=False)
85
+ print("TOPSIS completed successfully.")
86
+
87
+
88
+ if __name__ == "__main__":
89
+ main()