Topsis-Lakshay-102303872 0.0.1__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_lakshay_102303872-0.0.1/PKG-INFO +93 -0
- topsis_lakshay_102303872-0.0.1/README.md +82 -0
- topsis_lakshay_102303872-0.0.1/Topsis_Lakshay_102303872.egg-info/PKG-INFO +93 -0
- topsis_lakshay_102303872-0.0.1/Topsis_Lakshay_102303872.egg-info/SOURCES.txt +10 -0
- topsis_lakshay_102303872-0.0.1/Topsis_Lakshay_102303872.egg-info/dependency_links.txt +1 -0
- topsis_lakshay_102303872-0.0.1/Topsis_Lakshay_102303872.egg-info/entry_points.txt +2 -0
- topsis_lakshay_102303872-0.0.1/Topsis_Lakshay_102303872.egg-info/requires.txt +2 -0
- topsis_lakshay_102303872-0.0.1/Topsis_Lakshay_102303872.egg-info/top_level.txt +1 -0
- topsis_lakshay_102303872-0.0.1/pyproject.toml +21 -0
- topsis_lakshay_102303872-0.0.1/setup.cfg +4 -0
- topsis_lakshay_102303872-0.0.1/topsis_lakshay_102303872/__init__.py +2 -0
- topsis_lakshay_102303872-0.0.1/topsis_lakshay_102303872/topsis.py +84 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Lakshay-102303872
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: TOPSIS CLI tool for multi-criteria decision making
|
|
5
|
+
Author-email: Lakshay <lsawhney07@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: pandas
|
|
10
|
+
Requires-Dist: numpy
|
|
11
|
+
|
|
12
|
+
# Topsis-Lakshay-102303872
|
|
13
|
+
|
|
14
|
+
A Python package that implements **TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)** as a command-line tool.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Install the package from PyPI using pip:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install Topsis-Lakshay-102303872
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Command Line Usage
|
|
29
|
+
|
|
30
|
+
After installation, the TOPSIS program can be executed using the `topsis` command.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
topsis data.csv "1,1,1,2,1" "+,+,-,+,-" result.csv
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Input File Format
|
|
47
|
+
|
|
48
|
+
The input file must be a CSV file with:
|
|
49
|
+
- First column containing alternative names (non-numeric)
|
|
50
|
+
- Remaining columns containing numeric criteria values
|
|
51
|
+
|
|
52
|
+
Example `data.csv`:
|
|
53
|
+
```csv
|
|
54
|
+
Fund Name,P1,P2,P3,P4,P5
|
|
55
|
+
M1,0.67,0.45,6.5,42.6,12.56
|
|
56
|
+
M2,0.60,0.36,3.5,53.3,14.47
|
|
57
|
+
M3,0.82,0.67,3.8,63.1,17.10
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Output File Format
|
|
63
|
+
|
|
64
|
+
The output CSV file contains all original columns along with:
|
|
65
|
+
- **Topsis Score**
|
|
66
|
+
- **Rank**
|
|
67
|
+
|
|
68
|
+
A higher Topsis Score indicates a better alternative.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Validations Performed
|
|
73
|
+
|
|
74
|
+
- Correct number of command-line arguments
|
|
75
|
+
- Input file existence check
|
|
76
|
+
- Minimum of three columns in input file
|
|
77
|
+
- Numeric values in criteria columns
|
|
78
|
+
- Number of weights equals number of criteria
|
|
79
|
+
- Number of impacts equals number of criteria
|
|
80
|
+
- Impacts must be either `+` or `-`
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Author
|
|
85
|
+
|
|
86
|
+
Lakshay
|
|
87
|
+
Roll Number: 102303872
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT License
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Topsis-Lakshay-102303872
|
|
2
|
+
|
|
3
|
+
A Python package that implements **TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)** as a command-line tool.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the package from PyPI using pip:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install Topsis-Lakshay-102303872
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Command Line Usage
|
|
18
|
+
|
|
19
|
+
After installation, the TOPSIS program can be executed using the `topsis` command.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
topsis data.csv "1,1,1,2,1" "+,+,-,+,-" result.csv
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Input File Format
|
|
36
|
+
|
|
37
|
+
The input file must be a CSV file with:
|
|
38
|
+
- First column containing alternative names (non-numeric)
|
|
39
|
+
- Remaining columns containing numeric criteria values
|
|
40
|
+
|
|
41
|
+
Example `data.csv`:
|
|
42
|
+
```csv
|
|
43
|
+
Fund Name,P1,P2,P3,P4,P5
|
|
44
|
+
M1,0.67,0.45,6.5,42.6,12.56
|
|
45
|
+
M2,0.60,0.36,3.5,53.3,14.47
|
|
46
|
+
M3,0.82,0.67,3.8,63.1,17.10
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Output File Format
|
|
52
|
+
|
|
53
|
+
The output CSV file contains all original columns along with:
|
|
54
|
+
- **Topsis Score**
|
|
55
|
+
- **Rank**
|
|
56
|
+
|
|
57
|
+
A higher Topsis Score indicates a better alternative.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Validations Performed
|
|
62
|
+
|
|
63
|
+
- Correct number of command-line arguments
|
|
64
|
+
- Input file existence check
|
|
65
|
+
- Minimum of three columns in input file
|
|
66
|
+
- Numeric values in criteria columns
|
|
67
|
+
- Number of weights equals number of criteria
|
|
68
|
+
- Number of impacts equals number of criteria
|
|
69
|
+
- Impacts must be either `+` or `-`
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Author
|
|
74
|
+
|
|
75
|
+
Lakshay
|
|
76
|
+
Roll Number: 102303872
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT License
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Lakshay-102303872
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: TOPSIS CLI tool for multi-criteria decision making
|
|
5
|
+
Author-email: Lakshay <lsawhney07@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: pandas
|
|
10
|
+
Requires-Dist: numpy
|
|
11
|
+
|
|
12
|
+
# Topsis-Lakshay-102303872
|
|
13
|
+
|
|
14
|
+
A Python package that implements **TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)** as a command-line tool.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Install the package from PyPI using pip:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install Topsis-Lakshay-102303872
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Command Line Usage
|
|
29
|
+
|
|
30
|
+
After installation, the TOPSIS program can be executed using the `topsis` command.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
topsis <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
topsis data.csv "1,1,1,2,1" "+,+,-,+,-" result.csv
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Input File Format
|
|
47
|
+
|
|
48
|
+
The input file must be a CSV file with:
|
|
49
|
+
- First column containing alternative names (non-numeric)
|
|
50
|
+
- Remaining columns containing numeric criteria values
|
|
51
|
+
|
|
52
|
+
Example `data.csv`:
|
|
53
|
+
```csv
|
|
54
|
+
Fund Name,P1,P2,P3,P4,P5
|
|
55
|
+
M1,0.67,0.45,6.5,42.6,12.56
|
|
56
|
+
M2,0.60,0.36,3.5,53.3,14.47
|
|
57
|
+
M3,0.82,0.67,3.8,63.1,17.10
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Output File Format
|
|
63
|
+
|
|
64
|
+
The output CSV file contains all original columns along with:
|
|
65
|
+
- **Topsis Score**
|
|
66
|
+
- **Rank**
|
|
67
|
+
|
|
68
|
+
A higher Topsis Score indicates a better alternative.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Validations Performed
|
|
73
|
+
|
|
74
|
+
- Correct number of command-line arguments
|
|
75
|
+
- Input file existence check
|
|
76
|
+
- Minimum of three columns in input file
|
|
77
|
+
- Numeric values in criteria columns
|
|
78
|
+
- Number of weights equals number of criteria
|
|
79
|
+
- Number of impacts equals number of criteria
|
|
80
|
+
- Impacts must be either `+` or `-`
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Author
|
|
85
|
+
|
|
86
|
+
Lakshay
|
|
87
|
+
Roll Number: 102303872
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT License
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
Topsis_Lakshay_102303872.egg-info/PKG-INFO
|
|
4
|
+
Topsis_Lakshay_102303872.egg-info/SOURCES.txt
|
|
5
|
+
Topsis_Lakshay_102303872.egg-info/dependency_links.txt
|
|
6
|
+
Topsis_Lakshay_102303872.egg-info/entry_points.txt
|
|
7
|
+
Topsis_Lakshay_102303872.egg-info/requires.txt
|
|
8
|
+
Topsis_Lakshay_102303872.egg-info/top_level.txt
|
|
9
|
+
topsis_lakshay_102303872/__init__.py
|
|
10
|
+
topsis_lakshay_102303872/topsis.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
topsis_lakshay_102303872
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Topsis-Lakshay-102303872"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "TOPSIS CLI tool for multi-criteria decision making"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Lakshay", email = "lsawhney07@gmail.com"}
|
|
13
|
+
]
|
|
14
|
+
license = {text = "MIT"}
|
|
15
|
+
dependencies = ["pandas", "numpy"]
|
|
16
|
+
|
|
17
|
+
[tool.setuptools]
|
|
18
|
+
packages = ["topsis_lakshay_102303872"]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
topsis = "topsis_lakshay_102303872.topsis:main"
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
def topsis(input_file, weights, impacts, output_file):
|
|
7
|
+
|
|
8
|
+
# checking the file
|
|
9
|
+
if not os.path.isfile(input_file):
|
|
10
|
+
print("Error: Input file not found")
|
|
11
|
+
sys.exit(1)
|
|
12
|
+
|
|
13
|
+
df = pd.read_csv(input_file)
|
|
14
|
+
|
|
15
|
+
if df.shape[1] < 3:
|
|
16
|
+
print("Error: Input file must contain three or more columns")
|
|
17
|
+
sys.exit(1)
|
|
18
|
+
|
|
19
|
+
data = df.iloc[:, 1:].values
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
data = data.astype(float)
|
|
23
|
+
except:
|
|
24
|
+
print("Error: From 2nd column to last column must be numeric")
|
|
25
|
+
sys.exit(1)
|
|
26
|
+
|
|
27
|
+
weights = weights.split(',')
|
|
28
|
+
impacts = impacts.split(',')
|
|
29
|
+
|
|
30
|
+
if len(weights) != data.shape[1] or len(impacts) != data.shape[1]:
|
|
31
|
+
print("Error: Number of weights, impacts and columns must be same")
|
|
32
|
+
sys.exit(1)
|
|
33
|
+
|
|
34
|
+
weights = np.array(weights, dtype=float)
|
|
35
|
+
|
|
36
|
+
for i in impacts:
|
|
37
|
+
if i not in ['+', '-']:
|
|
38
|
+
print("Error: Impacts must be either + or -")
|
|
39
|
+
sys.exit(1)
|
|
40
|
+
|
|
41
|
+
# normalization
|
|
42
|
+
n_factor = np.sqrt((data ** 2).sum(axis=0))
|
|
43
|
+
normalized = data / n_factor
|
|
44
|
+
|
|
45
|
+
# applying the wieghts to normalized matrix
|
|
46
|
+
weighted = normalized * weights
|
|
47
|
+
|
|
48
|
+
# ideal best and ideal worst
|
|
49
|
+
ideal_best = []
|
|
50
|
+
ideal_worst = []
|
|
51
|
+
|
|
52
|
+
for i in range(len(impacts)):
|
|
53
|
+
if impacts[i] == '+':
|
|
54
|
+
ideal_best.append(weighted[:, i].max())
|
|
55
|
+
ideal_worst.append(weighted[:, i].min())
|
|
56
|
+
else:
|
|
57
|
+
ideal_best.append(weighted[:, i].min())
|
|
58
|
+
ideal_worst.append(weighted[:, i].max())
|
|
59
|
+
|
|
60
|
+
ideal_best = np.array(ideal_best)
|
|
61
|
+
ideal_worst = np.array(ideal_worst)
|
|
62
|
+
|
|
63
|
+
# finding the distance
|
|
64
|
+
dist_best = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
|
|
65
|
+
dist_worst = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
|
|
66
|
+
|
|
67
|
+
# score calculation
|
|
68
|
+
score = dist_worst / (dist_best + dist_worst)
|
|
69
|
+
|
|
70
|
+
df['Topsis Score'] = score
|
|
71
|
+
df['Rank'] = df['Topsis Score'].rank(ascending=False).astype(int)
|
|
72
|
+
|
|
73
|
+
df.to_csv(output_file, index=False)
|
|
74
|
+
print("TOPSIS successfully completed")
|
|
75
|
+
|
|
76
|
+
def main():
|
|
77
|
+
if len(sys.argv) != 5:
|
|
78
|
+
print("Usage: topsis <inputfile> <weights> <impacts> <outputfile>")
|
|
79
|
+
sys.exit(1)
|
|
80
|
+
|
|
81
|
+
topsis(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
main()
|