Topsis-Sommit-102303184 0.0.1__py3-none-any.whl → 0.0.3__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.
@@ -2,68 +2,70 @@ import sys
2
2
  import pandas as pd
3
3
  import numpy as np
4
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 -")
5
+ def main():
6
+ if len(sys.argv) != 5:
7
+ print("Error: Incorrect number of parameters")
39
8
  sys.exit(1)
40
9
 
41
- weights = np.array(weights, dtype=float)
10
+ input_file = sys.argv[1]
11
+ weights = sys.argv[2].split(',')
12
+ impacts = sys.argv[3].split(',')
13
+ output_file = sys.argv[4]
42
14
 
43
- norm = np.sqrt((data ** 2).sum())
44
- normalized_data = data / norm
45
- weighted_data = normalized_data * weights
15
+ try:
16
+ df = pd.read_csv(input_file)
17
+ except:
18
+ print("Error: File not found")
19
+ sys.exit(1)
20
+
21
+ if df.shape[1] < 3:
22
+ print("Error: Input file must contain three or more columns")
23
+ sys.exit(1)
24
+
25
+ data = df.iloc[:, 1:]
26
+
27
+ try:
28
+ data = data.astype(float)
29
+ except:
30
+ print("Error: From 2nd to last columns must contain numeric values only")
31
+ sys.exit(1)
32
+
33
+ if len(weights) != data.shape[1] or len(impacts) != data.shape[1]:
34
+ print("Error: Number of weights, impacts and columns must be same")
35
+ sys.exit(1)
36
+
37
+ for i in impacts:
38
+ if i not in ['+', '-']:
39
+ print("Error: Impacts must be either + or -")
40
+ sys.exit(1)
41
+
42
+ weights = np.array(weights, dtype=float)
43
+
44
+ norm = np.sqrt((data ** 2).sum())
45
+ normalized_data = data / norm
46
+ weighted_data = normalized_data * weights
46
47
 
47
- ideal_best = []
48
- ideal_worst = []
48
+ ideal_best = []
49
+ ideal_worst = []
49
50
 
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())
51
+ for i in range(len(impacts)):
52
+ if impacts[i] == '+':
53
+ ideal_best.append(weighted_data.iloc[:, i].max())
54
+ ideal_worst.append(weighted_data.iloc[:, i].min())
55
+ else:
56
+ ideal_best.append(weighted_data.iloc[:, i].min())
57
+ ideal_worst.append(weighted_data.iloc[:, i].max())
57
58
 
58
- ideal_best = np.array(ideal_best)
59
- ideal_worst = np.array(ideal_worst)
59
+ ideal_best = np.array(ideal_best)
60
+ ideal_worst = np.array(ideal_worst)
60
61
 
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))
62
+ distance_best = np.sqrt(((weighted_data - ideal_best) ** 2).sum(axis=1))
63
+ distance_worst = np.sqrt(((weighted_data - ideal_worst) ** 2).sum(axis=1))
63
64
 
64
- topsis_score = distance_worst / (distance_best + distance_worst)
65
+ topsis_score = distance_worst / (distance_best + distance_worst)
65
66
 
66
- df['Topsis Score'] = topsis_score
67
- df['Rank'] = topsis_score.rank(ascending=False)
67
+ df["Topsis Score"] = topsis_score
68
+ df["Rank"] = topsis_score.rank(ascending=False)
68
69
 
69
- df.to_csv(output_file, index=False)
70
+ df.to_csv(output_file, index=False)
71
+ print("Result saved to", output_file)
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-Sommit-102303184
3
+ Version: 0.0.3
4
+ Summary: TOPSIS implementation using Python
5
+ Author: Sommit
6
+ Author-email: sommit312@gmail.com
7
+ Keywords: 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 :: Microsoft :: Windows
12
+ Classifier: Operating System :: Unix
13
+ Classifier: Operating System :: MacOS
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: pandas
18
+ Requires-Dist: numpy
19
+ Dynamic: author
20
+ Dynamic: author-email
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: keywords
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # Topsis-Sommit-102303184
31
+
32
+ A Python package to perform TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) for multi-criteria decision making using the command line.
33
+
34
+ ## Installation
35
+
36
+ Install the package from PyPI:
37
+
38
+ ```bash
39
+ pip install Topsis-Sommit-102303184
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ Run TOPSIS from the command line as follows:
45
+
46
+ ```bash
47
+ topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>
48
+ ```
49
+
50
+ ### Example
51
+
52
+ ```bash
53
+ topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
54
+ ```
55
+
56
+ ## Input File Format
57
+
58
+ - Input file must be a CSV file
59
+ - First column contains alternatives (names)
60
+ - Remaining columns contain numerical criteria values
61
+
62
+ ### Sample Input (`data.csv`)
63
+
64
+ ```
65
+ Model,P1,P2,P3,P4
66
+ M1,250,16,12,5
67
+ M2,200,18,8,4
68
+ M3,300,14,10,6
69
+ ```
70
+
71
+ ## Parameters
72
+
73
+ - **InputDataFile**: Path to input CSV file
74
+ - **Weights**: Comma-separated numerical weights
75
+ - **Impacts**: Comma-separated impacts (`+` for benefit, `-` for cost)
76
+ - **ResultFileName**: Name of output CSV file
77
+
78
+ ## Output
79
+
80
+ The output CSV file will contain:
81
+ - **Topsis Score**
82
+ - **Rank** (1 indicates the best alternative)
83
+
84
+ ## Author
85
+
86
+ Sommit
87
+ Roll No: 102303184
88
+
89
+ ## License
90
+
91
+ MIT License
@@ -0,0 +1,8 @@
1
+ Topsis_Assignment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ Topsis_Assignment/topsis.py,sha256=zb3KHG-_NpOVJgVyMGqvnljeKlFEA_2R5sjkZDk3Hjs,2109
3
+ topsis_sommit_102303184-0.0.3.dist-info/licenses/LICENSE,sha256=aNYa__yyU_9C--4GsM5NE0DH3uc45kapftihka0eod0,1082
4
+ topsis_sommit_102303184-0.0.3.dist-info/METADATA,sha256=LPjZ1rOCY3-GxLCCghJ_3330quoMdCJooQCXMbhzer0,2059
5
+ topsis_sommit_102303184-0.0.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ topsis_sommit_102303184-0.0.3.dist-info/entry_points.txt,sha256=ldifNxmg9cP1nDdmg-jd2eI_t1XqNUX68-eaf3vZr1A,46
7
+ topsis_sommit_102303184-0.0.3.dist-info/top_level.txt,sha256=NQNPKnGztW6wsNeZtcjrjKih7_QhFFWrpR2KtrB3Abk,18
8
+ topsis_sommit_102303184-0.0.3.dist-info/RECORD,,
@@ -1,28 +0,0 @@
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.
@@ -1,8 +0,0 @@
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,,