Topsis-Satyam-102303729 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.
- topsis_satyam_102303729-1.0.0/PKG-INFO +32 -0
- topsis_satyam_102303729-1.0.0/Topsis_Satyam_102303729.egg-info/PKG-INFO +32 -0
- topsis_satyam_102303729-1.0.0/Topsis_Satyam_102303729.egg-info/SOURCES.txt +9 -0
- topsis_satyam_102303729-1.0.0/Topsis_Satyam_102303729.egg-info/dependency_links.txt +1 -0
- topsis_satyam_102303729-1.0.0/Topsis_Satyam_102303729.egg-info/entry_points.txt +2 -0
- topsis_satyam_102303729-1.0.0/Topsis_Satyam_102303729.egg-info/requires.txt +2 -0
- topsis_satyam_102303729-1.0.0/Topsis_Satyam_102303729.egg-info/top_level.txt +1 -0
- topsis_satyam_102303729-1.0.0/setup.cfg +4 -0
- topsis_satyam_102303729-1.0.0/setup.py +28 -0
- topsis_satyam_102303729-1.0.0/topsis/__init__.py +0 -0
- topsis_satyam_102303729-1.0.0/topsis/topsis.py +88 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Satyam-102303729
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Implementation of TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)
|
|
5
|
+
Home-page: https://github.com/sat-yam-12/TOPSIS-SATYAM-102303729
|
|
6
|
+
Author: Satyam Gupta
|
|
7
|
+
Author-email: sgupta5_be23@thapar.edu
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: pandas
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
# Topsis-Satyam-102303729
|
|
26
|
+
|
|
27
|
+
This is a Python package implementing the **TOPSIS** method
|
|
28
|
+
(Technique for Order Preference by Similarity to Ideal Solution).
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
```bash
|
|
32
|
+
pip install topsis-satyam-102303729
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Satyam-102303729
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Implementation of TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)
|
|
5
|
+
Home-page: https://github.com/sat-yam-12/TOPSIS-SATYAM-102303729
|
|
6
|
+
Author: Satyam Gupta
|
|
7
|
+
Author-email: sgupta5_be23@thapar.edu
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Requires-Dist: pandas
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
# Topsis-Satyam-102303729
|
|
26
|
+
|
|
27
|
+
This is a Python package implementing the **TOPSIS** method
|
|
28
|
+
(Technique for Order Preference by Similarity to Ideal Solution).
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
```bash
|
|
32
|
+
pip install topsis-satyam-102303729
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
setup.py
|
|
2
|
+
Topsis_Satyam_102303729.egg-info/PKG-INFO
|
|
3
|
+
Topsis_Satyam_102303729.egg-info/SOURCES.txt
|
|
4
|
+
Topsis_Satyam_102303729.egg-info/dependency_links.txt
|
|
5
|
+
Topsis_Satyam_102303729.egg-info/entry_points.txt
|
|
6
|
+
Topsis_Satyam_102303729.egg-info/requires.txt
|
|
7
|
+
Topsis_Satyam_102303729.egg-info/top_level.txt
|
|
8
|
+
topsis/__init__.py
|
|
9
|
+
topsis/topsis.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
topsis
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="Topsis-Satyam-102303729",
|
|
5
|
+
version="1.0.0",
|
|
6
|
+
author="Satyam Gupta",
|
|
7
|
+
author_email="sgupta5_be23@thapar.edu",
|
|
8
|
+
description="Implementation of TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)",
|
|
9
|
+
long_description=open("README.md").read(),
|
|
10
|
+
long_description_content_type="text/markdown",
|
|
11
|
+
url="https://github.com/sat-yam-12/TOPSIS-SATYAM-102303729",
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
install_requires=[
|
|
14
|
+
"numpy",
|
|
15
|
+
"pandas"
|
|
16
|
+
],
|
|
17
|
+
classifiers=[
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
],
|
|
22
|
+
python_requires=">=3.8",
|
|
23
|
+
entry_points={
|
|
24
|
+
"console_scripts": [
|
|
25
|
+
"topsis-satyam=topsis.topsis:main"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def run_topsis(input_file, weights, impacts, output_file):
|
|
8
|
+
if not os.path.isfile(input_file):
|
|
9
|
+
raise FileNotFoundError("Input file not found")
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
data = pd.read_csv(input_file)
|
|
13
|
+
except Exception:
|
|
14
|
+
raise ValueError("Unable to read input file")
|
|
15
|
+
|
|
16
|
+
if data.shape[1] < 3:
|
|
17
|
+
raise ValueError("Input file must contain at least 3 columns")
|
|
18
|
+
|
|
19
|
+
criteria = data.iloc[:, 1:]
|
|
20
|
+
|
|
21
|
+
criteria = criteria.apply(pd.to_numeric, errors="coerce")
|
|
22
|
+
if criteria.isnull().values.any():
|
|
23
|
+
raise ValueError("Non-numeric value found in criteria columns")
|
|
24
|
+
|
|
25
|
+
if len(weights) != criteria.shape[1] or len(impacts) != criteria.shape[1]:
|
|
26
|
+
raise ValueError("Number of weights/impacts must match number of criteria")
|
|
27
|
+
|
|
28
|
+
for i in impacts:
|
|
29
|
+
if i not in ['+', '-']:
|
|
30
|
+
raise ValueError("Impacts must be + or -")
|
|
31
|
+
|
|
32
|
+
# Step 1: Normalize
|
|
33
|
+
norm = criteria / np.sqrt((criteria ** 2).sum())
|
|
34
|
+
|
|
35
|
+
# Step 2: Apply weights
|
|
36
|
+
weighted = norm * weights
|
|
37
|
+
|
|
38
|
+
# Step 3: Ideal best and worst
|
|
39
|
+
ideal_best = []
|
|
40
|
+
ideal_worst = []
|
|
41
|
+
|
|
42
|
+
for i, impact in enumerate(impacts):
|
|
43
|
+
if impact == '+':
|
|
44
|
+
ideal_best.append(weighted.iloc[:, i].max())
|
|
45
|
+
ideal_worst.append(weighted.iloc[:, i].min())
|
|
46
|
+
else:
|
|
47
|
+
ideal_best.append(weighted.iloc[:, i].min())
|
|
48
|
+
ideal_worst.append(weighted.iloc[:, i].max())
|
|
49
|
+
|
|
50
|
+
ideal_best = np.array(ideal_best)
|
|
51
|
+
ideal_worst = np.array(ideal_worst)
|
|
52
|
+
|
|
53
|
+
# Step 4: Distance calculation
|
|
54
|
+
s_pos = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
|
|
55
|
+
s_neg = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
|
|
56
|
+
|
|
57
|
+
# Step 5: TOPSIS score
|
|
58
|
+
score = s_neg / (s_pos + s_neg)
|
|
59
|
+
|
|
60
|
+
# Step 6: Rank
|
|
61
|
+
data['Topsis Score'] = score
|
|
62
|
+
data['Rank'] = data['Topsis Score'].rank(
|
|
63
|
+
ascending=False, method='dense'
|
|
64
|
+
).astype(int)
|
|
65
|
+
|
|
66
|
+
data.to_csv(output_file, index=False)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def main():
|
|
70
|
+
if len(sys.argv) != 5:
|
|
71
|
+
print("Usage: topsis-satyam input.csv \"w1,w2,...\" \"+,-,+,...\" output.csv")
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
|
|
74
|
+
input_file = sys.argv[1]
|
|
75
|
+
weights = list(map(float, sys.argv[2].split(',')))
|
|
76
|
+
impacts = sys.argv[3].split(',')
|
|
77
|
+
output_file = sys.argv[4]
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
run_topsis(input_file, weights, impacts, output_file)
|
|
81
|
+
print("Output saved to", output_file)
|
|
82
|
+
except Exception as e:
|
|
83
|
+
print("Error:", e)
|
|
84
|
+
sys.exit(1)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if __name__ == "__main__":
|
|
88
|
+
main()
|