Topsis-KhushiMehta-102303769 1.0.0__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,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-KhushiMehta-102303769
3
+ Version: 1.0.0
4
+ Summary: TOPSIS decision making method
5
+ Author: Khushi
6
+ Requires-Dist: pandas
7
+ Requires-Dist: numpy
8
+ Requires-Dist: openpyxl
9
+ Dynamic: author
10
+ Dynamic: requires-dist
11
+ Dynamic: summary
@@ -0,0 +1,116 @@
1
+ TOPSIS Python Package
2
+
3
+ This project is a Python command-line tool that implements the TOPSIS
4
+ (Technique for Order Preference by Similarity to Ideal Solution) method.
5
+
6
+ TOPSIS is a multi-criteria decision making technique used to rank different
7
+ alternatives based on their distance from an ideal best solution and an
8
+ ideal worst solution.
9
+
10
+ This package allows users to apply the TOPSIS method easily using a single
11
+ command from the terminal.
12
+
13
+ -----------------------------------------------------------------------
14
+
15
+ Installation
16
+
17
+ The package can be installed using pip.
18
+
19
+ pip install Topsis-KhushiMehta-102303769
20
+
21
+ -----------------------------------------------------------------------
22
+
23
+ Usage
24
+
25
+ After installing the package, the TOPSIS method can be executed from the
26
+ command line using the following format:
27
+
28
+ topsis <input_file> <weights> <impacts> <output_file>
29
+
30
+ Example:
31
+
32
+ topsis data.csv "1,1,1" "+,+,+" result.csv
33
+
34
+ Here,
35
+ input_file : CSV or Excel (.xlsx) file containing the data
36
+ weights : Comma-separated numerical values indicating importance of criteria
37
+ impacts : Comma-separated symbols (+ or -) indicating benefit or cost criteria
38
+ output_file : CSV file where the result will be stored
39
+
40
+ -----------------------------------------------------------------------
41
+
42
+ Input File Format
43
+
44
+ The input file must be provided in CSV or Excel (.xlsx) format.
45
+
46
+ The first column of the file should contain the names of the alternatives.
47
+ All remaining columns must contain numeric values only.
48
+
49
+ Sample Input Table:
50
+
51
+ Alternative | C1 | C2 | C3
52
+ A1 | 250 | 16 | 12
53
+ A2 | 200 | 20 | 8
54
+ A3 | 300 | 14 | 16
55
+
56
+ -----------------------------------------------------------------------
57
+
58
+ Weights and Impacts
59
+
60
+ Weights represent the importance of each criterion.
61
+ They must be provided as comma-separated numeric values.
62
+
63
+ Example:
64
+ "1,1,1"
65
+
66
+ Impacts specify whether a criterion is beneficial or non-beneficial.
67
+ Use '+' for benefit criteria and '-' for cost criteria.
68
+
69
+ Example:
70
+ "+,+,-"
71
+
72
+ The number of weights and impacts must be equal to the number of criteria
73
+ columns in the input file.
74
+
75
+ -----------------------------------------------------------------------
76
+
77
+ Output File
78
+
79
+ The output is generated in CSV format.
80
+
81
+ Two additional columns are added to the original data:
82
+ Topsis Score
83
+ Rank
84
+
85
+ A higher Topsis Score indicates a better alternative.
86
+ The alternative with the highest score is assigned rank 1.
87
+
88
+ -----------------------------------------------------------------------
89
+
90
+ Error Handling
91
+
92
+ The program performs the following validations before processing the data:
93
+
94
+ Correct number of command-line arguments
95
+ Input file existence
96
+ Minimum of three columns in the input file
97
+ Numeric values in criteria columns
98
+ Matching number of weights, impacts, and criteria columns
99
+ Valid impact values (+ or -)
100
+
101
+ Appropriate error messages are displayed if any of the above conditions fail.
102
+
103
+ -----------------------------------------------------------------------
104
+
105
+ About TOPSIS
106
+
107
+ TOPSIS ranks alternatives based on their relative closeness to the ideal solution.
108
+ The alternative closest to the ideal best solution and farthest from the
109
+ ideal worst solution is considered the best option.
110
+
111
+ -----------------------------------------------------------------------
112
+
113
+ Author
114
+
115
+ Khushi Mehta
116
+ Developed as part of an academic assignment
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: Topsis-KhushiMehta-102303769
3
+ Version: 1.0.0
4
+ Summary: TOPSIS decision making method
5
+ Author: Khushi
6
+ Requires-Dist: pandas
7
+ Requires-Dist: numpy
8
+ Requires-Dist: openpyxl
9
+ Dynamic: author
10
+ Dynamic: requires-dist
11
+ Dynamic: summary
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ Topsis_KhushiMehta_102303769.egg-info/PKG-INFO
5
+ Topsis_KhushiMehta_102303769.egg-info/SOURCES.txt
6
+ Topsis_KhushiMehta_102303769.egg-info/dependency_links.txt
7
+ Topsis_KhushiMehta_102303769.egg-info/entry_points.txt
8
+ Topsis_KhushiMehta_102303769.egg-info/requires.txt
9
+ Topsis_KhushiMehta_102303769.egg-info/top_level.txt
10
+ topsis_khushi/__init__.py
11
+ topsis_khushi/topsis.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ topsis = topsis_khushi.topsis:main
@@ -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,15 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="Topsis-KhushiMehta-102303769",
5
+ version="1.0.0",
6
+ packages=find_packages(),
7
+ install_requires=["pandas", "numpy", "openpyxl"],
8
+ entry_points={
9
+ "console_scripts": [
10
+ "topsis=topsis_khushi.topsis:main"
11
+ ]
12
+ },
13
+ author="Khushi",
14
+ description="TOPSIS decision making method",
15
+ )
@@ -0,0 +1,81 @@
1
+
2
+ import sys
3
+ import os
4
+ import pandas as pd
5
+ import numpy as np
6
+
7
+ def topsis(input_file, weights, impacts, output_file):
8
+
9
+ # File check
10
+ if not os.path.exists(input_file):
11
+ raise Exception("Input file not found")
12
+
13
+ # INPUT (CSV or XLSX)
14
+ if input_file.endswith(".csv"):
15
+ df = pd.read_csv(input_file)
16
+ elif input_file.endswith(".xlsx"):
17
+ df = pd.read_excel(input_file)
18
+ else:
19
+ raise Exception("Input file must be .csv or .xlsx")
20
+
21
+ if df.shape[1] < 3:
22
+ raise Exception("Input file must contain 3 or more columns")
23
+
24
+ data = df.iloc[:, 1:]
25
+
26
+ # Numeric validation
27
+ if not np.all(data.map(np.isreal)):
28
+ raise Exception("Columns from 2nd to last must be numeric")
29
+
30
+ weights = list(map(float, weights.split(",")))
31
+ impacts = impacts.split(",")
32
+
33
+ if len(weights) != data.shape[1] or len(impacts) != data.shape[1]:
34
+ raise Exception("Weights, impacts and columns count mismatch")
35
+
36
+ for i in impacts:
37
+ if i not in ['+', '-']:
38
+ raise Exception("Impacts must be + or -")
39
+
40
+ # Normalization
41
+ norm = np.sqrt((data ** 2).sum())
42
+ norm_data = data / norm
43
+
44
+ # Weighted
45
+ weighted = norm_data * weights
46
+
47
+ # Ideal best & worst
48
+ ideal_best = []
49
+ ideal_worst = []
50
+
51
+ for i in range(len(impacts)):
52
+ if impacts[i] == '+':
53
+ ideal_best.append(weighted.iloc[:, i].max())
54
+ ideal_worst.append(weighted.iloc[:, i].min())
55
+ else:
56
+ ideal_best.append(weighted.iloc[:, i].min())
57
+ ideal_worst.append(weighted.iloc[:, i].max())
58
+
59
+ # Distance
60
+ d_best = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
61
+ d_worst = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
62
+
63
+ score = d_worst / (d_best + d_worst)
64
+
65
+ df["Topsis Score"] = score
66
+ df["Rank"] = score.rank(ascending=False)
67
+
68
+
69
+ if not output_file.endswith(".csv"):
70
+ raise Exception("Output file must be .csv")
71
+
72
+ df.to_csv(output_file, index=False)
73
+
74
+ def main():
75
+ if len(sys.argv) != 5:
76
+ print("Usage: topsis <input.(csv/xlsx)> <weights> <impacts> <output.csv>")
77
+ sys.exit(1)
78
+
79
+ _, input_file, weights, impacts, output_file = sys.argv
80
+ topsis(input_file, weights, impacts, output_file)
81
+