topsis-vani-102303064 1.0.2__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 Vani
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,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: topsis-vani-102303064
3
+ Version: 1.0.2
4
+ Summary: TOPSIS implementation as a Python package
5
+ Author: Vani
6
+ Author-email: vanimohindru7@gmail.com
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pandas
12
+ Requires-Dist: numpy
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: description
16
+ Dynamic: description-content-type
17
+ Dynamic: license
18
+ Dynamic: license-file
19
+ Dynamic: requires-dist
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+
24
+ # Topsis-Vani-102303064
25
+
26
+ This package implements the **TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)** method.
27
+ It is used to rank alternatives based on multiple criteria.
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+
35
+ pip install topsis-vani-102303064
36
+
37
+ ```
38
+
39
+ Usage (Command Line)
40
+
41
+ ```bash
42
+ topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
43
+ ```
44
+
45
+ Example
46
+ ```bash
47
+ topsis data.csv "1,1,1,2" "+,+,-,+" output.csv
48
+ ```
49
+
50
+ Input File Format
51
+ -CSV file
52
+ -Minimum 3 columns
53
+ -First column: alternative names (non-numeric)
54
+ -Remaining columns: numeric criteria values
55
+
56
+ Example Input
57
+ ```bash
58
+ Fund Name,P1,P2,P3,P4
59
+ M1,0.67,0.45,6.5,42.6
60
+ M2,0.60,0.36,3.6,53.3
61
+ M3,0.82,0.67,3.8,63.1
62
+ ```
63
+
64
+ Weights and Impacts
65
+ Weights (comma separated):
66
+ -1,1,1,2
67
+ Impacts (+ for benefit, - for cost):
68
+ -+,+,-,+
69
+
70
+ Output
71
+ -Output file is generated in CSV format
72
+ -Two new columns are added:
73
+ -Topsis Score
74
+ -Rank (Rank 1 = Best alternative)
75
+
76
+ License
77
+ -MIT License
78
+
79
+ Author
80
+ -Vani
81
+ -Roll Number: 102303064
@@ -0,0 +1,59 @@
1
+
2
+ # Topsis-Vani-102303064
3
+
4
+ This package implements the **TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)** method.
5
+ It is used to rank alternatives based on multiple criteria.
6
+
7
+ ---
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+
13
+ pip install topsis-vani-102303064
14
+
15
+ ```
16
+
17
+ Usage (Command Line)
18
+
19
+ ```bash
20
+ topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
21
+ ```
22
+
23
+ Example
24
+ ```bash
25
+ topsis data.csv "1,1,1,2" "+,+,-,+" output.csv
26
+ ```
27
+
28
+ Input File Format
29
+ -CSV file
30
+ -Minimum 3 columns
31
+ -First column: alternative names (non-numeric)
32
+ -Remaining columns: numeric criteria values
33
+
34
+ Example Input
35
+ ```bash
36
+ Fund Name,P1,P2,P3,P4
37
+ M1,0.67,0.45,6.5,42.6
38
+ M2,0.60,0.36,3.6,53.3
39
+ M3,0.82,0.67,3.8,63.1
40
+ ```
41
+
42
+ Weights and Impacts
43
+ Weights (comma separated):
44
+ -1,1,1,2
45
+ Impacts (+ for benefit, - for cost):
46
+ -+,+,-,+
47
+
48
+ Output
49
+ -Output file is generated in CSV format
50
+ -Two new columns are added:
51
+ -Topsis Score
52
+ -Rank (Rank 1 = Best alternative)
53
+
54
+ License
55
+ -MIT License
56
+
57
+ Author
58
+ -Vani
59
+ -Roll Number: 102303064
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="topsis-vani-102303064",
5
+ version="1.0.2",
6
+ author="Vani",
7
+ author_email="vanimohindru7@gmail.com",
8
+ description="TOPSIS implementation as a Python package",
9
+ long_description=open("README.md", encoding="utf-8").read(),
10
+ long_description_content_type="text/markdown",
11
+ packages=find_packages(),
12
+ install_requires=["pandas", "numpy"],
13
+ entry_points={
14
+ "console_scripts": [
15
+ "topsis=topsis_vani_102303064.pred_as1:main"
16
+ ]
17
+ },
18
+ license="MIT",
19
+ python_requires=">=3.8",
20
+ )
@@ -0,0 +1 @@
1
+ from .pred_as1 import main
@@ -0,0 +1,148 @@
1
+ import sys
2
+ import os
3
+ import pandas as pd
4
+ import numpy as np
5
+
6
+
7
+ def error_exit(msg):
8
+ print("Error:", msg)
9
+ sys.exit(1)
10
+
11
+
12
+ def main():
13
+ # --------------------------------------------------
14
+ # 1. Check number of command-line arguments
15
+ # --------------------------------------------------
16
+ if len(sys.argv) != 5:
17
+ error_exit(
18
+ "Incorrect number of parameters.\n"
19
+ "Usage: topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>"
20
+ )
21
+
22
+ input_file = sys.argv[1]
23
+ weights_str = sys.argv[2]
24
+ impacts_str = sys.argv[3]
25
+ output_file = sys.argv[4]
26
+
27
+ # --------------------------------------------------
28
+ # 2. Check if input file exists
29
+ # --------------------------------------------------
30
+ if not os.path.isfile(input_file):
31
+ error_exit("Input file not found.")
32
+
33
+ # --------------------------------------------------
34
+ # 3. Read input file (CSV or XLSX)
35
+ # --------------------------------------------------
36
+ try:
37
+ if input_file.endswith(".csv"):
38
+ data = pd.read_csv(input_file)
39
+ elif input_file.endswith(".xlsx"):
40
+ data = pd.read_excel(input_file)
41
+ else:
42
+ error_exit("Input file must be a .csv or .xlsx file.")
43
+ except Exception as e:
44
+ error_exit(f"Unable to read input file: {e}")
45
+
46
+ # --------------------------------------------------
47
+ # 4. Minimum column check (>= 3 columns)
48
+ # --------------------------------------------------
49
+ if data.shape[1] < 3:
50
+ error_exit("Input file must contain at least three columns.")
51
+
52
+ # --------------------------------------------------
53
+ # 5. Extract criteria columns (2nd to last)
54
+ # --------------------------------------------------
55
+ criteria = data.iloc[:, 1:]
56
+
57
+ # --------------------------------------------------
58
+ # 6. Check numeric values in criteria columns
59
+ # --------------------------------------------------
60
+ if not np.all(criteria.applymap(np.isreal)):
61
+ error_exit("From 2nd to last columns must contain numeric values only.")
62
+
63
+ # --------------------------------------------------
64
+ # 7. Validate comma-separated weights & impacts
65
+ # --------------------------------------------------
66
+ if "," not in weights_str:
67
+ error_exit("Weights must be separated by commas.")
68
+
69
+ if "," not in impacts_str:
70
+ error_exit("Impacts must be separated by commas.")
71
+
72
+ try:
73
+ weights = [float(w.strip()) for w in weights_str.split(",")]
74
+ impacts = [i.strip() for i in impacts_str.split(",")]
75
+ except:
76
+ error_exit("Invalid weights or impacts format.")
77
+
78
+ # --------------------------------------------------
79
+ # 8. Check counts match
80
+ # --------------------------------------------------
81
+ if len(weights) != criteria.shape[1] or len(impacts) != criteria.shape[1]:
82
+ error_exit(
83
+ "Number of weights, impacts, and criteria columns must be the same."
84
+ )
85
+
86
+ # --------------------------------------------------
87
+ # 9. Validate impacts (+ or - only)
88
+ # --------------------------------------------------
89
+ for imp in impacts:
90
+ if imp not in ['+', '-']:
91
+ error_exit("Impacts must be either '+' or '-'.")
92
+
93
+ # --------------------------------------------------
94
+ # ---------------- TOPSIS STEPS --------------------
95
+ # --------------------------------------------------
96
+
97
+ # Step 1: Normalize decision matrix
98
+ norm = np.sqrt((criteria ** 2).sum())
99
+ normalized = criteria / norm
100
+
101
+ # Step 2: Apply weights
102
+ weighted = normalized * weights
103
+
104
+ # Step 3: Ideal best and worst
105
+ ideal_best = []
106
+ ideal_worst = []
107
+
108
+ for i in range(len(impacts)):
109
+ if impacts[i] == '+':
110
+ ideal_best.append(weighted.iloc[:, i].max())
111
+ ideal_worst.append(weighted.iloc[:, i].min())
112
+ else:
113
+ ideal_best.append(weighted.iloc[:, i].min())
114
+ ideal_worst.append(weighted.iloc[:, i].max())
115
+
116
+ ideal_best = np.array(ideal_best)
117
+ ideal_worst = np.array(ideal_worst)
118
+
119
+ # Step 4: Distance from ideal best and worst
120
+ dist_best = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
121
+ dist_worst = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
122
+
123
+ # Step 5: TOPSIS score
124
+ topsis_score = dist_worst / (dist_best + dist_worst)
125
+
126
+ # Step 6: Rank (higher score = better)
127
+ rank = topsis_score.rank(ascending=False, method='dense').astype(int)
128
+
129
+ # --------------------------------------------------
130
+ # 10. Prepare output
131
+ # --------------------------------------------------
132
+ result = data.copy()
133
+ result["Topsis Score"] = topsis_score.round(4)
134
+ result["Rank"] = rank
135
+
136
+ # --------------------------------------------------
137
+ # 11. Save output file
138
+ # --------------------------------------------------
139
+ try:
140
+ result.to_csv(output_file, index=False)
141
+ print("TOPSIS analysis completed successfully.")
142
+ print(f"Output saved to: {output_file}")
143
+ except Exception as e:
144
+ error_exit(f"Unable to write output file: {e}")
145
+
146
+
147
+ if __name__ == "__main__":
148
+ main()
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: topsis-vani-102303064
3
+ Version: 1.0.2
4
+ Summary: TOPSIS implementation as a Python package
5
+ Author: Vani
6
+ Author-email: vanimohindru7@gmail.com
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: pandas
12
+ Requires-Dist: numpy
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: description
16
+ Dynamic: description-content-type
17
+ Dynamic: license
18
+ Dynamic: license-file
19
+ Dynamic: requires-dist
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+
24
+ # Topsis-Vani-102303064
25
+
26
+ This package implements the **TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)** method.
27
+ It is used to rank alternatives based on multiple criteria.
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+
35
+ pip install topsis-vani-102303064
36
+
37
+ ```
38
+
39
+ Usage (Command Line)
40
+
41
+ ```bash
42
+ topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
43
+ ```
44
+
45
+ Example
46
+ ```bash
47
+ topsis data.csv "1,1,1,2" "+,+,-,+" output.csv
48
+ ```
49
+
50
+ Input File Format
51
+ -CSV file
52
+ -Minimum 3 columns
53
+ -First column: alternative names (non-numeric)
54
+ -Remaining columns: numeric criteria values
55
+
56
+ Example Input
57
+ ```bash
58
+ Fund Name,P1,P2,P3,P4
59
+ M1,0.67,0.45,6.5,42.6
60
+ M2,0.60,0.36,3.6,53.3
61
+ M3,0.82,0.67,3.8,63.1
62
+ ```
63
+
64
+ Weights and Impacts
65
+ Weights (comma separated):
66
+ -1,1,1,2
67
+ Impacts (+ for benefit, - for cost):
68
+ -+,+,-,+
69
+
70
+ Output
71
+ -Output file is generated in CSV format
72
+ -Two new columns are added:
73
+ -Topsis Score
74
+ -Rank (Rank 1 = Best alternative)
75
+
76
+ License
77
+ -MIT License
78
+
79
+ Author
80
+ -Vani
81
+ -Roll Number: 102303064
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ topsis_vani_102303064/__init__.py
6
+ topsis_vani_102303064/pred_as1.py
7
+ topsis_vani_102303064.egg-info/PKG-INFO
8
+ topsis_vani_102303064.egg-info/SOURCES.txt
9
+ topsis_vani_102303064.egg-info/dependency_links.txt
10
+ topsis_vani_102303064.egg-info/entry_points.txt
11
+ topsis_vani_102303064.egg-info/requires.txt
12
+ topsis_vani_102303064.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ topsis = topsis_vani_102303064.pred_as1:main
@@ -0,0 +1 @@
1
+ topsis_vani_102303064