Topsis-Sommit-102303184 0.0.1__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,69 @@
1
+ import sys
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+ if len(sys.argv) != 5:
6
+ print("Error: Incorrect number of parameters")
7
+ sys.exit(1)
8
+
9
+ input_file = sys.argv[1]
10
+ weights = sys.argv[2].split(',')
11
+ impacts = sys.argv[3].split(',')
12
+ output_file = sys.argv[4]
13
+
14
+ try:
15
+ df = pd.read_csv(input_file)
16
+ except:
17
+ print("Error: File not found")
18
+ sys.exit(1)
19
+
20
+ if df.shape[1] < 3:
21
+ print("Error: Input file must contain three or more columns")
22
+ sys.exit(1)
23
+
24
+ data = df.iloc[:, 1:]
25
+
26
+ try:
27
+ data = data.astype(float)
28
+ except:
29
+ print("Error: From 2nd to last columns must contain numeric values only")
30
+ sys.exit(1)
31
+
32
+ if len(weights) != data.shape[1] or len(impacts) != data.shape[1]:
33
+ print("Error: Number of weights, impacts and columns must be same")
34
+ sys.exit(1)
35
+
36
+ for i in impacts:
37
+ if i not in ['+', '-']:
38
+ print("Error: Impacts must be either + or -")
39
+ sys.exit(1)
40
+
41
+ weights = np.array(weights, dtype=float)
42
+
43
+ norm = np.sqrt((data ** 2).sum())
44
+ normalized_data = data / norm
45
+ weighted_data = normalized_data * weights
46
+
47
+ ideal_best = []
48
+ ideal_worst = []
49
+
50
+ for i in range(len(impacts)):
51
+ if impacts[i] == '+':
52
+ ideal_best.append(weighted_data.iloc[:, i].max())
53
+ ideal_worst.append(weighted_data.iloc[:, i].min())
54
+ else:
55
+ ideal_best.append(weighted_data.iloc[:, i].min())
56
+ ideal_worst.append(weighted_data.iloc[:, i].max())
57
+
58
+ ideal_best = np.array(ideal_best)
59
+ ideal_worst = np.array(ideal_worst)
60
+
61
+ distance_best = np.sqrt(((weighted_data - ideal_best) ** 2).sum(axis=1))
62
+ distance_worst = np.sqrt(((weighted_data - ideal_worst) ** 2).sum(axis=1))
63
+
64
+ topsis_score = distance_worst / (distance_best + distance_worst)
65
+
66
+ df['Topsis Score'] = topsis_score
67
+ df['Rank'] = topsis_score.rank(ascending=False)
68
+
69
+ df.to_csv(output_file, index=False)
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-Sommit-102303184
3
+ Version: 0.0.1
4
+ Summary: TOPSIS implementation using Python
5
+ Author: Sommit
6
+ Author-email: sommit312@gmail.com
7
+ Keywords: python,topsis,mcdm,decision making,ranking
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: Unix
12
+ Classifier: Operating System :: MacOS :: MacOS X
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pandas
17
+ Requires-Dist: numpy
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: keywords
24
+ Dynamic: license-file
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
27
+
28
+ A Python package to perform TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) using command line.
@@ -0,0 +1,8 @@
1
+ Topsis_Assignment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ Topsis_Assignment/topsis.py,sha256=1nXqix0ztVI_tRe6h8oHx4DKmiCaX20psH-8r4jz_tw,1857
3
+ topsis_sommit_102303184-0.0.1.dist-info/licenses/LICENSE,sha256=aNYa__yyU_9C--4GsM5NE0DH3uc45kapftihka0eod0,1082
4
+ topsis_sommit_102303184-0.0.1.dist-info/METADATA,sha256=JVvc8RHvSoigOercSYDRIadlRIQBvacGaWt9xPaBsnU,934
5
+ topsis_sommit_102303184-0.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ topsis_sommit_102303184-0.0.1.dist-info/entry_points.txt,sha256=ldifNxmg9cP1nDdmg-jd2eI_t1XqNUX68-eaf3vZr1A,46
7
+ topsis_sommit_102303184-0.0.1.dist-info/top_level.txt,sha256=NQNPKnGztW6wsNeZtcjrjKih7_QhFFWrpR2KtrB3Abk,18
8
+ topsis_sommit_102303184-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ topsis = topsis.topsis:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Sommit
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 @@
1
+ Topsis_Assignment