Topsis-Prabhsimar-102483078 1.0.2__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,77 @@
1
+ import pandas as pd
2
+ import numpy as np
3
+ import sys
4
+ import os
5
+
6
+ def topsis():
7
+ if len(sys.argv) != 5:
8
+ print("Usage: topsis <InputFile> <Weights> <Impacts> <OutputFile>")
9
+ sys.exit(1)
10
+
11
+ input_file = sys.argv[1]
12
+ weights = sys.argv[2]
13
+ impacts = sys.argv[3]
14
+ output_file = sys.argv[4]
15
+
16
+ if not os.path.isfile(input_file):
17
+ print("Error: Input file not found")
18
+ sys.exit(1)
19
+
20
+ data = pd.read_csv(input_file)
21
+
22
+ if data.shape[1] < 3:
23
+ print("Error: Input file must contain at least 3 columns")
24
+ sys.exit(1)
25
+
26
+ try:
27
+ criteria = data.iloc[:, 1:].astype(float)
28
+ except:
29
+ print("Error: Criteria columns must be numeric")
30
+ sys.exit(1)
31
+
32
+ weights = weights.split(",")
33
+ impacts = impacts.split(",")
34
+
35
+ if len(weights) != criteria.shape[1] or len(impacts) != criteria.shape[1]:
36
+ print("Error: Number of weights, impacts, and criteria columns must match")
37
+ sys.exit(1)
38
+
39
+ try:
40
+ weights = np.array(weights, dtype=float)
41
+ except:
42
+ print("Error: Weights must be numeric")
43
+ sys.exit(1)
44
+
45
+ for i in impacts:
46
+ if i not in ["+", "-"]:
47
+ print("Error: Impacts must be '+' or '-'")
48
+ sys.exit(1)
49
+
50
+ norm = np.sqrt((criteria ** 2).sum())
51
+ normalized = criteria / norm
52
+ weighted = normalized * weights
53
+
54
+ ideal_best = []
55
+ ideal_worst = []
56
+
57
+ for i in range(weighted.shape[1]):
58
+ if impacts[i] == "+":
59
+ ideal_best.append(weighted.iloc[:, i].max())
60
+ ideal_worst.append(weighted.iloc[:, i].min())
61
+ else:
62
+ ideal_best.append(weighted.iloc[:, i].min())
63
+ ideal_worst.append(weighted.iloc[:, i].max())
64
+
65
+ ideal_best = np.array(ideal_best)
66
+ ideal_worst = np.array(ideal_worst)
67
+
68
+ dist_best = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
69
+ dist_worst = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
70
+
71
+ score = dist_worst / (dist_best + dist_worst)
72
+ rank = score.rank(ascending=False, method="dense")
73
+
74
+ data["Topsis Score"] = score
75
+ data["Rank"] = rank.astype(int)
76
+
77
+ data.to_csv(output_file, index=False)
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-Prabhsimar-102483078
3
+ Version: 1.0.2
4
+ Summary: A Python package for TOPSIS multi-criteria decision making
5
+ Author: Prabhsimar Singh
6
+ Author-email: prabhsimar@example.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Intended Audience :: Education
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pandas
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ # Topsis-Prabhsimar-102483078
26
+
27
+ PyPI version | License: MIT
28
+
29
+ ---
30
+
31
+ ## 📌 Description
32
+
33
+ This package implements the **TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)** method, a popular **multi-criteria decision-making (MCDM)** technique.
34
+
35
+ TOPSIS is used to rank alternatives based on their relative distance from:
36
+ - an **ideal best solution**
37
+ - an **ideal worst solution**
38
+
39
+ It helps decision-makers choose the best option among multiple alternatives.
40
+
41
+ ---
42
+
43
+ ## 🧠 Applications of TOPSIS
44
+
45
+ TOPSIS is widely used in:
46
+ - Product selection and comparison
47
+ - Supplier evaluation
48
+ - Project prioritization
49
+ - Performance assessment
50
+ - Resource allocation
51
+ - Investment analysis
52
+
53
+ ---
54
+
55
+ ## ⚙️ Installation
56
+
57
+ Install the package using pip:
58
+
59
+ ```bash
60
+ pip install Topsis-Prabhsimar-102483078
61
+ ```
62
+
63
+ ## 🚀 Usage
64
+
65
+ After installation, the topsis command becomes available in the terminal.
66
+
67
+ ### Basic Syntax
68
+
69
+ ```
70
+ topsis <input_csv> <weights> <impacts> <output_csv>
71
+ ```
72
+
73
+ ### Parameters
74
+
75
+ | Parameter | Description |
76
+ |-----------|-------------|
77
+ | input_csv | Path to the CSV file containing the decision matrix |
78
+ | weights | Comma-separated numerical weights for each criterion |
79
+ | impacts | Comma-separated impacts (+ for benefit, - for cost) |
80
+ | output_csv | Path where the output CSV file will be saved |
81
+
82
+ ---
83
+
84
+ ## 📊 Example
85
+
86
+ ### Input File (sample.csv)
87
+
88
+ ```
89
+ Model,Storage(in GB),Camera(in MP),Price(in $),Rating
90
+ M1,16,12,250,5
91
+ M2,16,8,200,3
92
+ M3,32,16,300,4
93
+ M4,32,8,275,4
94
+ M5,16,16,225,2
95
+ ```
96
+
97
+ ### Decision Criteria
98
+
99
+ **Weights Vector**
100
+ ```
101
+ 0.25,0.25,0.25,0.25
102
+ ```
103
+
104
+ **Impacts Vector**
105
+ ```
106
+ +,+,-,+
107
+ ```
108
+
109
+ - Storage → Benefit (+)
110
+ - Camera → Benefit (+)
111
+ - Price → Cost (-)
112
+ - Rating → Benefit (+)
113
+
114
+ ### Command
115
+
116
+ ```bash
117
+ topsis sample.csv "0.25,0.25,0.25,0.25" "+,+,-,+" output.csv
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 📈 Output
123
+
124
+ The output CSV file will contain two additional columns:
125
+ - Topsis Score (closeness coefficient)
126
+ - Rank
127
+
128
+ ### Sample Output
129
+
130
+ | Model | Storage | Camera | Price | Rating | Topsis Score | Rank |
131
+ |-------|---------|--------|-------|--------|--------------|------|
132
+ | M3 | 32 | 16 | 300 | 4 | 0.69 | 1 |
133
+ | M4 | 32 | 8 | 275 | 4 | 0.53 | 2 |
134
+ | M1 | 16 | 12 | 250 | 5 | 0.53 | 3 |
135
+ | M5 | 16 | 16 | 225 | 2 | 0.40 | 4 |
136
+ | M2 | 16 | 8 | 200 | 3 | 0.30 | 5 |
137
+
138
+ ---
139
+
140
+ ## 📋 Input File Requirements
141
+
142
+ - CSV format only
143
+ - First column must contain alternative names
144
+ - Remaining columns must be numeric
145
+ - No missing values
146
+ - Minimum 2 criteria columns required
147
+
148
+ ---
149
+
150
+ ## ⚠️ Important Notes
151
+
152
+ - Number of weights must equal number of criteria columns
153
+ - Number of impacts must equal number of criteria columns
154
+ - Weights must be positive numbers
155
+ - Impacts must be either + or -
156
+ - All criterion values must be numeric
157
+
158
+ ---
159
+
160
+ ## 🔧 How TOPSIS Works
161
+
162
+ 1. Normalize the decision matrix
163
+ 2. Apply weights to normalized values
164
+ 3. Determine ideal best and ideal worst solutions
165
+ 4. Compute distances from ideal best and worst
166
+ 5. Calculate closeness coefficient
167
+ 6. Rank alternatives based on score
168
+
169
+ ---
170
+
171
+ ## 📝 License
172
+
173
+ This project is licensed under the MIT License.
174
+
175
+ ---
176
+
177
+ ## 👤 Author
178
+
179
+ **Prabhsimar Singh**
180
+ Roll Number: 102483078
181
+
182
+ ---
183
+
184
+ ## 📚 Academic Note
185
+
186
+ This package was developed as part of an academic assignment for
187
+ **UCS654 – Prescriptive Analytics**
@@ -0,0 +1,7 @@
1
+ topsis_prabhsimar_102483078/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ topsis_prabhsimar_102483078/topsis.py,sha256=4VO1TbQJNhJ53QI_sfcGkC8ER0WHDUMRrfCqkHY0oc8,2218
3
+ topsis_prabhsimar_102483078-1.0.2.dist-info/METADATA,sha256=L_0JsbKSRJNzvoHqr__0rSDM3PodbdMo2brbaTRdqWY,4170
4
+ topsis_prabhsimar_102483078-1.0.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
5
+ topsis_prabhsimar_102483078-1.0.2.dist-info/entry_points.txt,sha256=-xG7ox2cMZZ6958zmhBwjYsRDZ-1ts5lO34C_u8_-ws,69
6
+ topsis_prabhsimar_102483078-1.0.2.dist-info/top_level.txt,sha256=s0iIJ5EWpX3S9-acA0_ph0vEkIr8G8J41TAm9a6TEAU,28
7
+ topsis_prabhsimar_102483078-1.0.2.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_prabhsimar_102483078.topsis:topsis
@@ -0,0 +1 @@
1
+ topsis_prabhsimar_102483078