Topsis-Rakshita-102303498 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_rakshita_102303498-1.0.0/PKG-INFO +82 -0
- topsis_rakshita_102303498-1.0.0/Topsis_Rakshita_102303498.egg-info/PKG-INFO +82 -0
- topsis_rakshita_102303498-1.0.0/Topsis_Rakshita_102303498.egg-info/SOURCES.txt +10 -0
- topsis_rakshita_102303498-1.0.0/Topsis_Rakshita_102303498.egg-info/dependency_links.txt +1 -0
- topsis_rakshita_102303498-1.0.0/Topsis_Rakshita_102303498.egg-info/entry_points.txt +2 -0
- topsis_rakshita_102303498-1.0.0/Topsis_Rakshita_102303498.egg-info/requires.txt +2 -0
- topsis_rakshita_102303498-1.0.0/Topsis_Rakshita_102303498.egg-info/top_level.txt +1 -0
- topsis_rakshita_102303498-1.0.0/pyproject.toml +4 -0
- topsis_rakshita_102303498-1.0.0/setup.cfg +4 -0
- topsis_rakshita_102303498-1.0.0/setup.py +17 -0
- topsis_rakshita_102303498-1.0.0/topsis/__init__.py +1 -0
- topsis_rakshita_102303498-1.0.0/topsis/topsis.py +68 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Rakshita-102303498
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: TOPSIS implementation for MCDM problems
|
|
5
|
+
Author: Rakshita Garg
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy
|
|
8
|
+
Requires-Dist: pandas
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: description
|
|
11
|
+
Dynamic: description-content-type
|
|
12
|
+
Dynamic: requires-dist
|
|
13
|
+
Dynamic: summary
|
|
14
|
+
|
|
15
|
+
# topsis-3283
|
|
16
|
+
|
|
17
|
+
## Project Description
|
|
18
|
+
|
|
19
|
+
**topsis-3283** is a Python library developed for solving **Multiple Criteria Decision Making (MCDM)** problems using the
|
|
20
|
+
**Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS)** method.
|
|
21
|
+
|
|
22
|
+
This project is developed as part of academic coursework and provides a command-line interface to rank alternatives based on multiple criteria, weights, and impacts.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## What is TOPSIS?
|
|
29
|
+
|
|
30
|
+
TOPSIS is a decision-making method based on the concept that the chosen alternative should have the **shortest distance from the ideal solution** and the **farthest distance from the negative-ideal solution**.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Use the Python package manager `pip` to install the package from PyPI:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install topsis-3283
|
|
40
|
+
|
|
41
|
+
Usage
|
|
42
|
+
Run the package from the command line using the following format:
|
|
43
|
+
topsis <input_file.csv> <weights> <impacts>
|
|
44
|
+
Example Commands
|
|
45
|
+
topsis sample.csv "1,1,1,1" "+,-,+,+"
|
|
46
|
+
OR (without quotes):
|
|
47
|
+
topsis sample.csv 1,1,1,1 +,-,+,+
|
|
48
|
+
⚠️ Note:
|
|
49
|
+
If the input vectors contain spaces, they must be enclosed in double quotes " ".
|
|
50
|
+
To view help:
|
|
51
|
+
topsis /h
|
|
52
|
+
Example
|
|
53
|
+
Sample Input File (sample.csv)
|
|
54
|
+
A CSV file containing data for different mobile handsets:
|
|
55
|
+
Model Storage space (GB) Camera (MP) Price ($) Looks (out of 5)
|
|
56
|
+
M1 16 12 250 5
|
|
57
|
+
M2 16 8 200 3
|
|
58
|
+
M3 32 16 300 4
|
|
59
|
+
M4 32 8 275 4
|
|
60
|
+
M5 16 16 225 2
|
|
61
|
+
Weights Vector
|
|
62
|
+
[0.25, 0.25, 0.25, 0.25]
|
|
63
|
+
Impacts Vector
|
|
64
|
+
[+, +, -, +]
|
|
65
|
+
Command Used
|
|
66
|
+
topsis sample.csv "0.25,0.25,0.25,0.25" "+,+,-,+"
|
|
67
|
+
Output
|
|
68
|
+
TOPSIS RESULTS
|
|
69
|
+
-----------------------------
|
|
70
|
+
|
|
71
|
+
P-Score Rank
|
|
72
|
+
1 0.534277 3
|
|
73
|
+
2 0.308368 5
|
|
74
|
+
3 0.691632 1
|
|
75
|
+
4 0.534737 2
|
|
76
|
+
5 0.401046 4
|
|
77
|
+
Other Notes
|
|
78
|
+
The first column and first row are removed automatically to eliminate indices and headers.
|
|
79
|
+
Ensure the CSV file:
|
|
80
|
+
Contains only numerical values (except the first column)
|
|
81
|
+
Does not contain categorical data
|
|
82
|
+
Follows the same structure as sample.csv
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Topsis-Rakshita-102303498
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: TOPSIS implementation for MCDM problems
|
|
5
|
+
Author: Rakshita Garg
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: numpy
|
|
8
|
+
Requires-Dist: pandas
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: description
|
|
11
|
+
Dynamic: description-content-type
|
|
12
|
+
Dynamic: requires-dist
|
|
13
|
+
Dynamic: summary
|
|
14
|
+
|
|
15
|
+
# topsis-3283
|
|
16
|
+
|
|
17
|
+
## Project Description
|
|
18
|
+
|
|
19
|
+
**topsis-3283** is a Python library developed for solving **Multiple Criteria Decision Making (MCDM)** problems using the
|
|
20
|
+
**Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS)** method.
|
|
21
|
+
|
|
22
|
+
This project is developed as part of academic coursework and provides a command-line interface to rank alternatives based on multiple criteria, weights, and impacts.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## What is TOPSIS?
|
|
29
|
+
|
|
30
|
+
TOPSIS is a decision-making method based on the concept that the chosen alternative should have the **shortest distance from the ideal solution** and the **farthest distance from the negative-ideal solution**.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Use the Python package manager `pip` to install the package from PyPI:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install topsis-3283
|
|
40
|
+
|
|
41
|
+
Usage
|
|
42
|
+
Run the package from the command line using the following format:
|
|
43
|
+
topsis <input_file.csv> <weights> <impacts>
|
|
44
|
+
Example Commands
|
|
45
|
+
topsis sample.csv "1,1,1,1" "+,-,+,+"
|
|
46
|
+
OR (without quotes):
|
|
47
|
+
topsis sample.csv 1,1,1,1 +,-,+,+
|
|
48
|
+
⚠️ Note:
|
|
49
|
+
If the input vectors contain spaces, they must be enclosed in double quotes " ".
|
|
50
|
+
To view help:
|
|
51
|
+
topsis /h
|
|
52
|
+
Example
|
|
53
|
+
Sample Input File (sample.csv)
|
|
54
|
+
A CSV file containing data for different mobile handsets:
|
|
55
|
+
Model Storage space (GB) Camera (MP) Price ($) Looks (out of 5)
|
|
56
|
+
M1 16 12 250 5
|
|
57
|
+
M2 16 8 200 3
|
|
58
|
+
M3 32 16 300 4
|
|
59
|
+
M4 32 8 275 4
|
|
60
|
+
M5 16 16 225 2
|
|
61
|
+
Weights Vector
|
|
62
|
+
[0.25, 0.25, 0.25, 0.25]
|
|
63
|
+
Impacts Vector
|
|
64
|
+
[+, +, -, +]
|
|
65
|
+
Command Used
|
|
66
|
+
topsis sample.csv "0.25,0.25,0.25,0.25" "+,+,-,+"
|
|
67
|
+
Output
|
|
68
|
+
TOPSIS RESULTS
|
|
69
|
+
-----------------------------
|
|
70
|
+
|
|
71
|
+
P-Score Rank
|
|
72
|
+
1 0.534277 3
|
|
73
|
+
2 0.308368 5
|
|
74
|
+
3 0.691632 1
|
|
75
|
+
4 0.534737 2
|
|
76
|
+
5 0.401046 4
|
|
77
|
+
Other Notes
|
|
78
|
+
The first column and first row are removed automatically to eliminate indices and headers.
|
|
79
|
+
Ensure the CSV file:
|
|
80
|
+
Contains only numerical values (except the first column)
|
|
81
|
+
Does not contain categorical data
|
|
82
|
+
Follows the same structure as sample.csv
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
pyproject.toml
|
|
2
|
+
setup.py
|
|
3
|
+
Topsis_Rakshita_102303498.egg-info/PKG-INFO
|
|
4
|
+
Topsis_Rakshita_102303498.egg-info/SOURCES.txt
|
|
5
|
+
Topsis_Rakshita_102303498.egg-info/dependency_links.txt
|
|
6
|
+
Topsis_Rakshita_102303498.egg-info/entry_points.txt
|
|
7
|
+
Topsis_Rakshita_102303498.egg-info/requires.txt
|
|
8
|
+
Topsis_Rakshita_102303498.egg-info/top_level.txt
|
|
9
|
+
topsis/__init__.py
|
|
10
|
+
topsis/topsis.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
topsis
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="Topsis-Rakshita-102303498",
|
|
5
|
+
version="1.0.0",
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
install_requires=["numpy", "pandas"],
|
|
8
|
+
entry_points={
|
|
9
|
+
"console_scripts": [
|
|
10
|
+
"topsis=topsis.topsis:main"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
author="Rakshita Garg",
|
|
14
|
+
description="TOPSIS implementation for MCDM problems",
|
|
15
|
+
long_description=open("README.md", encoding="utf-8").read(),
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .topsis import topsis
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import numpy as np
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def topsis(input_file, weights, impacts, output_file):
|
|
7
|
+
data = pd.read_csv(input_file)
|
|
8
|
+
|
|
9
|
+
if len(weights) != len(impacts) or len(weights) != data.shape[1] - 1:
|
|
10
|
+
raise ValueError("Number of weights, impacts and criteria must match")
|
|
11
|
+
|
|
12
|
+
matrix = data.iloc[:, 1:].values.astype(float)
|
|
13
|
+
|
|
14
|
+
# Step 1: Normalize
|
|
15
|
+
norm = np.sqrt((matrix ** 2).sum(axis=0))
|
|
16
|
+
matrix = matrix / norm
|
|
17
|
+
|
|
18
|
+
# Step 2: Apply weights
|
|
19
|
+
matrix = matrix * weights
|
|
20
|
+
|
|
21
|
+
# Step 3: Ideal best and worst
|
|
22
|
+
ideal_best = []
|
|
23
|
+
ideal_worst = []
|
|
24
|
+
|
|
25
|
+
for i in range(len(impacts)):
|
|
26
|
+
if impacts[i] == '+':
|
|
27
|
+
ideal_best.append(matrix[:, i].max())
|
|
28
|
+
ideal_worst.append(matrix[:, i].min())
|
|
29
|
+
else:
|
|
30
|
+
ideal_best.append(matrix[:, i].min())
|
|
31
|
+
ideal_worst.append(matrix[:, i].max())
|
|
32
|
+
|
|
33
|
+
ideal_best = np.array(ideal_best)
|
|
34
|
+
ideal_worst = np.array(ideal_worst)
|
|
35
|
+
|
|
36
|
+
# Step 4: Distances
|
|
37
|
+
dist_best = np.sqrt(((matrix - ideal_best) ** 2).sum(axis=1))
|
|
38
|
+
dist_worst = np.sqrt(((matrix - ideal_worst) ** 2).sum(axis=1))
|
|
39
|
+
|
|
40
|
+
# Step 5: Score
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
score = dist_worst / (dist_best + dist_worst)
|
|
44
|
+
|
|
45
|
+
data["Topsis Score"] = score
|
|
46
|
+
data["Rank"] = pd.Series(score).rank(ascending=False).astype(int)
|
|
47
|
+
|
|
48
|
+
data.to_csv(output_file, index=False)
|
|
49
|
+
print("Output file created:", output_file)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def main():
|
|
55
|
+
if len(sys.argv) != 5:
|
|
56
|
+
print("Usage: topsis <input_file> <weights> <impacts> <output_file>")
|
|
57
|
+
sys.exit(1)
|
|
58
|
+
|
|
59
|
+
input_file = sys.argv[1]
|
|
60
|
+
weights = list(map(float, sys.argv[2].split(",")))
|
|
61
|
+
impacts = sys.argv[3].split(",")
|
|
62
|
+
output_file = sys.argv[4]
|
|
63
|
+
|
|
64
|
+
topsis(input_file, weights, impacts, output_file)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
main()
|