Topsis-Sommit-102303184 0.0.2__tar.gz → 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.
@@ -1,27 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Topsis-Sommit-102303184
3
- Version: 0.0.2
4
- Summary: TOPSIS implementation using Python
3
+ Version: 0.2
4
+ Summary: TOPSIS implementation using command line
5
5
  Author: Sommit
6
6
  Author-email: sommit312@gmail.com
7
- Keywords: python,topsis,mcdm,decision making,ranking
8
- Classifier: Development Status :: 3 - Alpha
9
- Classifier: Intended Audience :: Education
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Operating System :: Microsoft :: Windows
12
- Classifier: Operating System :: MacOS :: MacOS X
13
- Classifier: Operating System :: Unix
14
7
  Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
8
  Requires-Dist: pandas
17
9
  Requires-Dist: numpy
18
10
  Dynamic: author
19
11
  Dynamic: author-email
20
- Dynamic: classifier
21
12
  Dynamic: description
22
13
  Dynamic: description-content-type
23
- Dynamic: keywords
24
- Dynamic: license-file
25
14
  Dynamic: requires-dist
26
15
  Dynamic: summary
27
16
 
@@ -33,23 +22,23 @@ A Python package to perform TOPSIS (Technique for Order Preference by Similarity
33
22
 
34
23
  Install the package from PyPI:
35
24
 
36
- ```bash
25
+ bash
37
26
  pip install Topsis-Sommit-102303184
38
- ```
27
+
39
28
 
40
29
  ## Usage
41
30
 
42
31
  Run TOPSIS from the command line as follows:
43
32
 
44
- ```bash
33
+ bash
45
34
  topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>
46
- ```
35
+
47
36
 
48
37
  ### Example
49
38
 
50
- ```bash
39
+ bash
51
40
  topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
52
- ```
41
+
53
42
 
54
43
  ## Input File Format
55
44
 
@@ -57,27 +46,27 @@ topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
57
46
  - First column contains alternatives (names)
58
47
  - Remaining columns contain numerical criteria values
59
48
 
60
- ### Sample Input (`data.csv`)
49
+ ### Sample Input (data.csv)
50
+
61
51
 
62
- ```
63
52
  Model,P1,P2,P3,P4
64
53
  M1,250,16,12,5
65
54
  M2,200,18,8,4
66
55
  M3,300,14,10,6
67
- ```
56
+
68
57
 
69
58
  ## Parameters
70
59
 
71
- - **InputDataFile**: Path to input CSV file
72
- - **Weights**: Comma-separated numerical weights
73
- - **Impacts**: Comma-separated impacts (`+` for benefit, `-` for cost)
74
- - **ResultFileName**: Name of output CSV file
60
+ - *InputDataFile*: Path to input CSV file
61
+ - *Weights*: Comma-separated numerical weights
62
+ - *Impacts*: Comma-separated impacts (+ for benefit, - for cost)
63
+ - *ResultFileName*: Name of output CSV file
75
64
 
76
65
  ## Output
77
66
 
78
67
  The output CSV file will contain:
79
- - **Topsis Score**
80
- - **Rank** (1 indicates the best alternative)
68
+ - *Topsis Score*
69
+ - *Rank* (1 indicates the best alternative)
81
70
 
82
71
  ## Author
83
72
 
@@ -6,23 +6,23 @@ A Python package to perform TOPSIS (Technique for Order Preference by Similarity
6
6
 
7
7
  Install the package from PyPI:
8
8
 
9
- ```bash
9
+ bash
10
10
  pip install Topsis-Sommit-102303184
11
- ```
11
+
12
12
 
13
13
  ## Usage
14
14
 
15
15
  Run TOPSIS from the command line as follows:
16
16
 
17
- ```bash
17
+ bash
18
18
  topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>
19
- ```
19
+
20
20
 
21
21
  ### Example
22
22
 
23
- ```bash
23
+ bash
24
24
  topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
25
- ```
25
+
26
26
 
27
27
  ## Input File Format
28
28
 
@@ -30,27 +30,27 @@ topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
30
30
  - First column contains alternatives (names)
31
31
  - Remaining columns contain numerical criteria values
32
32
 
33
- ### Sample Input (`data.csv`)
33
+ ### Sample Input (data.csv)
34
+
34
35
 
35
- ```
36
36
  Model,P1,P2,P3,P4
37
37
  M1,250,16,12,5
38
38
  M2,200,18,8,4
39
39
  M3,300,14,10,6
40
- ```
40
+
41
41
 
42
42
  ## Parameters
43
43
 
44
- - **InputDataFile**: Path to input CSV file
45
- - **Weights**: Comma-separated numerical weights
46
- - **Impacts**: Comma-separated impacts (`+` for benefit, `-` for cost)
47
- - **ResultFileName**: Name of output CSV file
44
+ - *InputDataFile*: Path to input CSV file
45
+ - *Weights*: Comma-separated numerical weights
46
+ - *Impacts*: Comma-separated impacts (+ for benefit, - for cost)
47
+ - *ResultFileName*: Name of output CSV file
48
48
 
49
49
  ## Output
50
50
 
51
51
  The output CSV file will contain:
52
- - **Topsis Score**
53
- - **Rank** (1 indicates the best alternative)
52
+ - *Topsis Score*
53
+ - *Rank* (1 indicates the best alternative)
54
54
 
55
55
  ## Author
56
56
 
@@ -59,4 +59,4 @@ Roll No: 102303184
59
59
 
60
60
  ## License
61
61
 
62
- MIT License
62
+ MIT License
@@ -1,27 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Topsis-Sommit-102303184
3
- Version: 0.0.2
4
- Summary: TOPSIS implementation using Python
3
+ Version: 0.2
4
+ Summary: TOPSIS implementation using command line
5
5
  Author: Sommit
6
6
  Author-email: sommit312@gmail.com
7
- Keywords: python,topsis,mcdm,decision making,ranking
8
- Classifier: Development Status :: 3 - Alpha
9
- Classifier: Intended Audience :: Education
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Operating System :: Microsoft :: Windows
12
- Classifier: Operating System :: MacOS :: MacOS X
13
- Classifier: Operating System :: Unix
14
7
  Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
8
  Requires-Dist: pandas
17
9
  Requires-Dist: numpy
18
10
  Dynamic: author
19
11
  Dynamic: author-email
20
- Dynamic: classifier
21
12
  Dynamic: description
22
13
  Dynamic: description-content-type
23
- Dynamic: keywords
24
- Dynamic: license-file
25
14
  Dynamic: requires-dist
26
15
  Dynamic: summary
27
16
 
@@ -33,23 +22,23 @@ A Python package to perform TOPSIS (Technique for Order Preference by Similarity
33
22
 
34
23
  Install the package from PyPI:
35
24
 
36
- ```bash
25
+ bash
37
26
  pip install Topsis-Sommit-102303184
38
- ```
27
+
39
28
 
40
29
  ## Usage
41
30
 
42
31
  Run TOPSIS from the command line as follows:
43
32
 
44
- ```bash
33
+ bash
45
34
  topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>
46
- ```
35
+
47
36
 
48
37
  ### Example
49
38
 
50
- ```bash
39
+ bash
51
40
  topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
52
- ```
41
+
53
42
 
54
43
  ## Input File Format
55
44
 
@@ -57,27 +46,27 @@ topsis data.csv "1,1,1,2" "+,+,-,+" result.csv
57
46
  - First column contains alternatives (names)
58
47
  - Remaining columns contain numerical criteria values
59
48
 
60
- ### Sample Input (`data.csv`)
49
+ ### Sample Input (data.csv)
50
+
61
51
 
62
- ```
63
52
  Model,P1,P2,P3,P4
64
53
  M1,250,16,12,5
65
54
  M2,200,18,8,4
66
55
  M3,300,14,10,6
67
- ```
56
+
68
57
 
69
58
  ## Parameters
70
59
 
71
- - **InputDataFile**: Path to input CSV file
72
- - **Weights**: Comma-separated numerical weights
73
- - **Impacts**: Comma-separated impacts (`+` for benefit, `-` for cost)
74
- - **ResultFileName**: Name of output CSV file
60
+ - *InputDataFile*: Path to input CSV file
61
+ - *Weights*: Comma-separated numerical weights
62
+ - *Impacts*: Comma-separated impacts (+ for benefit, - for cost)
63
+ - *ResultFileName*: Name of output CSV file
75
64
 
76
65
  ## Output
77
66
 
78
67
  The output CSV file will contain:
79
- - **Topsis Score**
80
- - **Rank** (1 indicates the best alternative)
68
+ - *Topsis Score*
69
+ - *Rank* (1 indicates the best alternative)
81
70
 
82
71
  ## Author
83
72
 
@@ -1,11 +1,10 @@
1
- LICENSE
2
1
  README.md
3
2
  setup.py
4
- Topsis_Assignment/__init__.py
5
- Topsis_Assignment/topsis.py
6
3
  Topsis_Sommit_102303184.egg-info/PKG-INFO
7
4
  Topsis_Sommit_102303184.egg-info/SOURCES.txt
8
5
  Topsis_Sommit_102303184.egg-info/dependency_links.txt
9
6
  Topsis_Sommit_102303184.egg-info/entry_points.txt
10
7
  Topsis_Sommit_102303184.egg-info/requires.txt
11
- Topsis_Sommit_102303184.egg-info/top_level.txt
8
+ Topsis_Sommit_102303184.egg-info/top_level.txt
9
+ topsis_sommit_102303184/__init__.py
10
+ topsis_sommit_102303184/topsis.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ topsis = topsis_sommit_102303184.topsis:main
@@ -0,0 +1 @@
1
+ topsis_sommit_102303184
@@ -0,0 +1,22 @@
1
+ from setuptools import setup, find_packages
2
+ from pathlib import Path
3
+
4
+ this_directory = Path(__file__).parent
5
+ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
6
+
7
+ setup(
8
+ name='Topsis-Sommit-102303184',
9
+ version='0.2',
10
+ author='Sommit',
11
+ author_email='sommit312@gmail.com',
12
+ description='TOPSIS implementation using command line',
13
+ long_description=long_description,
14
+ long_description_content_type='text/markdown',
15
+ packages=find_packages(),
16
+ install_requires=['pandas', 'numpy'],
17
+ entry_points={
18
+ 'console_scripts': [
19
+ 'topsis=topsis_sommit_102303184.topsis:main',
20
+ ],
21
+ },
22
+ )
@@ -0,0 +1,70 @@
1
+ import sys
2
+ import pandas as pd
3
+ import numpy as np
4
+
5
+ def main():
6
+ if len(sys.argv) != 5:
7
+ print("Error: Incorrect number of parameters")
8
+ sys.exit()
9
+
10
+ file = sys.argv[1]
11
+ weights = sys.argv[2].split(',')
12
+ impacts = sys.argv[3].split(',')
13
+ out = sys.argv[4]
14
+
15
+ try:
16
+ df = pd.read_csv(file)
17
+ except:
18
+ print("Error: File not found")
19
+ sys.exit()
20
+
21
+ if df.shape[1] < 3:
22
+ print("Error: Input file must contain three or more columns")
23
+ sys.exit()
24
+
25
+ data = df.iloc[:, 1:]
26
+
27
+ try:
28
+ data = data.astype(float)
29
+ except:
30
+ print("Error: From 2nd to last columns must contain numeric values only")
31
+ sys.exit()
32
+
33
+ if len(weights) != data.shape[1] or len(impacts) != data.shape[1]:
34
+ print("Error: Number of weights, impacts and columns must be same")
35
+ sys.exit()
36
+
37
+ for i in impacts:
38
+ if i not in ['+', '-']:
39
+ print("Error: Impacts must be either + or -")
40
+ sys.exit()
41
+
42
+ weights = [float(i) for i in weights]
43
+
44
+ norm = (data**2).sum()**0.5
45
+ data = data / norm
46
+ data = data * weights
47
+
48
+ best = []
49
+ worst = []
50
+
51
+ for i in range(len(impacts)):
52
+ if impacts[i] == '+':
53
+ best.append(max(data.iloc[:, i]))
54
+ worst.append(min(data.iloc[:, i]))
55
+ else:
56
+ best.append(min(data.iloc[:, i]))
57
+ worst.append(max(data.iloc[:, i]))
58
+
59
+ best = np.array(best)
60
+ worst = np.array(worst)
61
+
62
+ d1 = ((data - best)**2).sum(axis=1)**0.5
63
+ d2 = ((data - worst)**2).sum(axis=1)**0.5
64
+
65
+ score = d2 / (d1 + d2)
66
+
67
+ df['Topsis Score'] = score
68
+ df['Rank'] = score.rank(ascending=False)
69
+
70
+ df.to_csv(out, index=False)
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Sommit
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.
@@ -1,69 +0,0 @@
1
- import sys
2
- import pandas as pd
3
- import numpy as np
4
-
5
- if len(sys.argv) != 5:
6
- print("Error: Incorrect number of parameters")
7
- sys.exit(1)
8
-
9
- input_file = sys.argv[1]
10
- weights = sys.argv[2].split(',')
11
- impacts = sys.argv[3].split(',')
12
- output_file = sys.argv[4]
13
-
14
- try:
15
- df = pd.read_csv(input_file)
16
- except:
17
- print("Error: File not found")
18
- sys.exit(1)
19
-
20
- if df.shape[1] < 3:
21
- print("Error: Input file must contain three or more columns")
22
- sys.exit(1)
23
-
24
- data = df.iloc[:, 1:]
25
-
26
- try:
27
- data = data.astype(float)
28
- except:
29
- print("Error: From 2nd to last columns must contain numeric values only")
30
- sys.exit(1)
31
-
32
- if len(weights) != data.shape[1] or len(impacts) != data.shape[1]:
33
- print("Error: Number of weights, impacts and columns must be same")
34
- sys.exit(1)
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
- weights = np.array(weights, dtype=float)
42
-
43
- norm = np.sqrt((data ** 2).sum())
44
- normalized_data = data / norm
45
- weighted_data = normalized_data * weights
46
-
47
- ideal_best = []
48
- ideal_worst = []
49
-
50
- for i in range(len(impacts)):
51
- if impacts[i] == '+':
52
- ideal_best.append(weighted_data.iloc[:, i].max())
53
- ideal_worst.append(weighted_data.iloc[:, i].min())
54
- else:
55
- ideal_best.append(weighted_data.iloc[:, i].min())
56
- ideal_worst.append(weighted_data.iloc[:, i].max())
57
-
58
- ideal_best = np.array(ideal_best)
59
- ideal_worst = np.array(ideal_worst)
60
-
61
- distance_best = np.sqrt(((weighted_data - ideal_best) ** 2).sum(axis=1))
62
- distance_worst = np.sqrt(((weighted_data - ideal_worst) ** 2).sum(axis=1))
63
-
64
- topsis_score = distance_worst / (distance_best + distance_worst)
65
-
66
- df['Topsis Score'] = topsis_score
67
- df['Rank'] = topsis_score.rank(ascending=False)
68
-
69
- df.to_csv(output_file, index=False)
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- topsis = topsis.topsis:main
@@ -1,30 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- with open("README.md", "r", encoding="utf-8") as f:
4
- long_description = f.read()
5
-
6
- setup(
7
- name="Topsis-Sommit-102303184",
8
- version="0.0.2",
9
- author="Sommit",
10
- author_email="sommit312@gmail.com",
11
- description="TOPSIS implementation using Python",
12
- long_description=long_description,
13
- long_description_content_type="text/markdown",
14
- packages=find_packages(),
15
- install_requires=["pandas", "numpy"],
16
- entry_points={
17
- "console_scripts": [
18
- "topsis=topsis.topsis:main"
19
- ]
20
- },
21
- keywords=["python", "topsis", "mcdm", "decision making", "ranking"],
22
- classifiers=[
23
- "Development Status :: 3 - Alpha",
24
- "Intended Audience :: Education",
25
- "Programming Language :: Python :: 3",
26
- "Operating System :: Microsoft :: Windows",
27
- "Operating System :: MacOS :: MacOS X",
28
- "Operating System :: Unix",
29
- ],
30
- )