Topsis-Diya-102303694 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.
@@ -0,0 +1,2 @@
1
+ __version__ = "1.0.0"
2
+
@@ -0,0 +1,80 @@
1
+ import sys
2
+ import os
3
+ import pandas as pd
4
+ import numpy as np
5
+
6
+ def error(msg):
7
+ print("Error:", msg)
8
+ sys.exit(1)
9
+
10
+ def main():
11
+ if len(sys.argv) != 5:
12
+ error("Usage: python topsis.py <InputDataFile> <Weights> <Impacts> <OutputFileName>")
13
+
14
+ inp = sys.argv[1]
15
+ w_str = sys.argv[2]
16
+ imp_str = sys.argv[3]
17
+ out = sys.argv[4]
18
+
19
+ if not os.path.isfile(inp):
20
+ error("Input file not found")
21
+
22
+ try:
23
+ df = pd.read_csv(inp)
24
+ except:
25
+ error("Cannot read input file")
26
+
27
+ if df.shape[1] < 3:
28
+ error("Input file must have at least three columns")
29
+
30
+ data = df.iloc[:, 1:]
31
+
32
+ if not np.all(data.applymap(np.isreal)):
33
+ error("Columns from 2nd onward must be numeric")
34
+
35
+ try:
36
+ w = list(map(float, w_str.split(',')))
37
+ imp = imp_str.split(',')
38
+ except:
39
+ error("Weights and impacts must be comma separated")
40
+
41
+ if len(w) != data.shape[1] or len(imp) != data.shape[1]:
42
+ error("Number of weights, impacts and columns must be same")
43
+
44
+ for i in imp:
45
+ if i not in ['+', '-']:
46
+ error("Impacts must be + or -")
47
+
48
+ norm = data / np.sqrt((data ** 2).sum())
49
+ w_norm = norm * w
50
+
51
+ best = []
52
+ worst = []
53
+
54
+ for i in range(len(imp)):
55
+ if imp[i] == '+':
56
+ best.append(w_norm.iloc[:, i].max())
57
+ worst.append(w_norm.iloc[:, i].min())
58
+ else:
59
+ best.append(w_norm.iloc[:, i].min())
60
+ worst.append(w_norm.iloc[:, i].max())
61
+
62
+ best = np.array(best)
63
+ worst = np.array(worst)
64
+
65
+ d_best = np.sqrt(((w_norm - best) ** 2).sum(axis=1))
66
+ d_worst = np.sqrt(((w_norm - worst) ** 2).sum(axis=1))
67
+
68
+ score = d_worst / (d_best + d_worst)
69
+
70
+ df["Topsis Score"] = score.round(4)
71
+ df["Rank"] = df["Topsis Score"].rank(ascending=False, method="dense").astype(int)
72
+
73
+ df.to_csv(out, index=False)
74
+ print("Result saved in", out)
75
+
76
+ def run():
77
+ main()
78
+
79
+ if __name__ == "__main__":
80
+ main()
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-Diya-102303694
3
+ Version: 1.0.0
4
+ Summary: A Python package for TOPSIS decision making
5
+ Author: Diya Singla
6
+ Author-email: diya@example.com
7
+ License: MIT
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
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: license
22
+ Dynamic: license-file
23
+ Dynamic: requires-dist
24
+ Dynamic: requires-python
25
+ Dynamic: summary
26
+
27
+
28
+ # Topsis-Diya-102303694
29
+
30
+ ## Project Description
31
+
32
+ **For:** Project-1 (UCS654 – Predictive Analytics)
33
+ **Submitted by:** Diya
34
+ **Roll Number:** 102303694
35
+
36
+ **Topsis-Diya-102303694** is a Python package designed to solve **Multiple Criteria Decision Making (MCDM)** problems using the **Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS)** method.
37
+
38
+ The package ranks multiple alternatives based on their relative distance from the ideal best and ideal worst solutions. It is implemented as a **command-line tool**, making it easy to use for real-world decision-making applications.
39
+
40
+ ---
41
+
42
+ ## Installation
43
+
44
+ Install the package using `pip`:
45
+
46
+ ```bash
47
+ pip install Topsis-Diya-102303694
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Usage
53
+
54
+ Run the package from the command line by providing:
55
+
56
+ - Input CSV file
57
+ - Weights vector
58
+ - Impacts vector
59
+ - Output file name
60
+
61
+ ```bash
62
+ topsis data.csv "1,1,1,2" "+,-,-,+" result.csv
63
+ ```
64
+
65
+ If vectors contain spaces, they must be enclosed within double quotes (`" "`).
66
+
67
+ ---
68
+
69
+ ## Input Format
70
+
71
+ - Input file must be in **CSV format**
72
+ - First column contains **alternatives** (e.g., items, models, options)
73
+ - Remaining columns contain **numeric criteria values**
74
+ - Minimum of **three columns** required
75
+ - No categorical values allowed in criteria columns
76
+
77
+ ---
78
+
79
+ ## Example
80
+
81
+ ### Sample Input File (`data.csv`)
82
+
83
+ ```csv
84
+ Fund Name,P1,P2,P3,P4
85
+ M1,0.67,0.45,6.5,42.6
86
+ M2,0.60,0.36,3.6,53.3
87
+ M3,0.82,0.67,3.8,63.1
88
+ M4,0.60,0.36,3.5,69.2
89
+ M5,0.76,0.58,4.8,43.0
90
+ ```
91
+
92
+ ### Command
93
+
94
+ ```bash
95
+ topsis data.csv "1,1,1,2" "+,-,-,+" result.csv
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Output
101
+
102
+ The output CSV file contains:
103
+
104
+ - Original input data
105
+ - **TOPSIS Score** for each alternative
106
+ - **Rank** based on TOPSIS score
107
+ (Higher score indicates better rank)
108
+
109
+ ---
110
+
111
+ ## Features
112
+
113
+ - Command-line based execution
114
+ - Supports user-defined weights and impacts
115
+ - Input validation and error handling
116
+ - Ranks alternatives using TOPSIS method
117
+ - Generates results in CSV format
118
+
119
+ ---
120
+
121
+ ## Notes
122
+
123
+ - Number of weights must match number of criteria
124
+ - Number of impacts must match number of criteria
125
+ - Impacts must be either `+` or `-`
126
+ - Input CSV must contain only numeric values (except first column)
127
+
128
+ ---
129
+
130
+ ## License
131
+
132
+ [MIT License](https://opensource.org/licenses/MIT)
133
+ ```
134
+
135
+
@@ -0,0 +1,8 @@
1
+ topsis_Diya_102303694/__init__.py,sha256=uyfGiipFnhOCQlqywx7wsgp6d-SYnqPqsPQd_xePZl8,23
2
+ topsis_Diya_102303694/topsis.py,sha256=MldclMvnHF71BNo6jg16-0mMOmRm0TE7XN4hI5hGT9s,1959
3
+ topsis_diya_102303694-1.0.0.dist-info/licenses/LICENSE,sha256=NwzMk9-AlPRDhRQXIYm7SbRt76Bd8pcgJ2_GNxySWVE,1072
4
+ topsis_diya_102303694-1.0.0.dist-info/METADATA,sha256=KkU1hoKLGzpjnj4ueENZtlWZS1dzb7xrlPlvACV7iVk,3033
5
+ topsis_diya_102303694-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ topsis_diya_102303694-1.0.0.dist-info/entry_points.txt,sha256=wehxyLpV6x20ghSb6jzrPcR92xoDvpl9-n-4u1bWBG4,60
7
+ topsis_diya_102303694-1.0.0.dist-info/top_level.txt,sha256=r6fDmNTdd2MlLBPuQ_QqIMKFW6kHLXmZbpnV56tO-Ts,22
8
+ topsis_diya_102303694-1.0.0.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_diya_102303694.topsis:run
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tanya Mediratta
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_Diya_102303694