matplotlid 1.0.0__py3-none-any.whl
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.
- matplotlid/__init__.py +8 -0
- matplotlid/__main__.py +28 -0
- matplotlid/programs.py +203 -0
- matplotlid-1.0.0.dist-info/METADATA +57 -0
- matplotlid-1.0.0.dist-info/RECORD +7 -0
- matplotlid-1.0.0.dist-info/WHEEL +5 -0
- matplotlid-1.0.0.dist-info/top_level.txt +1 -0
matplotlid/__init__.py
ADDED
matplotlid/__main__.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from .programs import PROGRAMS, TITLES
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
args = sys.argv[1:]
|
|
7
|
+
|
|
8
|
+
if not args:
|
|
9
|
+
print("Available MapReduce Programs:")
|
|
10
|
+
print("----------------------------")
|
|
11
|
+
for num, title in TITLES.items():
|
|
12
|
+
print(f" [{num}] {title}")
|
|
13
|
+
print("\nUsage: python -m matplotlid <program_number>")
|
|
14
|
+
print("Example: python -m matplotlid 1")
|
|
15
|
+
return
|
|
16
|
+
|
|
17
|
+
prog_num = args[0].strip()
|
|
18
|
+
|
|
19
|
+
if prog_num in PROGRAMS:
|
|
20
|
+
print(PROGRAMS[prog_num], end="")
|
|
21
|
+
else:
|
|
22
|
+
print(f"Error: Program '{prog_num}' not found.")
|
|
23
|
+
print("Available program numbers: " + ", ".join(PROGRAMS.keys()))
|
|
24
|
+
sys.exit(1)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
main()
|
matplotlid/programs.py
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
PROGRAMS = {
|
|
2
|
+
"1": """# 1) MapReduce Program to Implement Matrix Multiplication
|
|
3
|
+
|
|
4
|
+
r1, c1 = map(int, input("Enter rows,columns of Matrix A: ").split())
|
|
5
|
+
print("Enter Matrix A:")
|
|
6
|
+
A = []
|
|
7
|
+
for i in range(r1):
|
|
8
|
+
A.append(list(map(int, input().split())))
|
|
9
|
+
|
|
10
|
+
r2, c2 = map(int, input("Enter rows,columns of Matrix B: ").split())
|
|
11
|
+
|
|
12
|
+
if c1 != r2:
|
|
13
|
+
print("Not Possible: columns of A must equal rows of B")
|
|
14
|
+
exit()
|
|
15
|
+
|
|
16
|
+
print("Enter Matrix B:")
|
|
17
|
+
B = []
|
|
18
|
+
for i in range(r2):
|
|
19
|
+
B.append(list(map(int, input().split())))
|
|
20
|
+
|
|
21
|
+
mapped = []
|
|
22
|
+
|
|
23
|
+
for i in range(r1):
|
|
24
|
+
for j in range(c2):
|
|
25
|
+
for k in range(c1):
|
|
26
|
+
mapped.append(((i, j), A[i][k] * B[k][j]))
|
|
27
|
+
|
|
28
|
+
grouped = {}
|
|
29
|
+
|
|
30
|
+
for key, value in mapped:
|
|
31
|
+
if key not in grouped:
|
|
32
|
+
grouped[key] = []
|
|
33
|
+
grouped[key].append(value)
|
|
34
|
+
|
|
35
|
+
result = {}
|
|
36
|
+
|
|
37
|
+
for key, values in grouped.items():
|
|
38
|
+
result[key] = sum(values)
|
|
39
|
+
|
|
40
|
+
print("Output:")
|
|
41
|
+
for i in range(r1):
|
|
42
|
+
for j in range(c2):
|
|
43
|
+
print(i, j, result[(i, j)])
|
|
44
|
+
""",
|
|
45
|
+
"2": """# 2) MapReduce Program to Find the Maximum Electrical Consumption in Each Year
|
|
46
|
+
|
|
47
|
+
n = int(input("Enter number of records: "))
|
|
48
|
+
data = []
|
|
49
|
+
|
|
50
|
+
print("Enter Year Consumption:")
|
|
51
|
+
for i in range(n):
|
|
52
|
+
data.append(input().split())
|
|
53
|
+
|
|
54
|
+
mapped = []
|
|
55
|
+
|
|
56
|
+
for year, consumption in data:
|
|
57
|
+
mapped.append((year, int(consumption)))
|
|
58
|
+
|
|
59
|
+
grouped = {}
|
|
60
|
+
|
|
61
|
+
for year, consumption in mapped:
|
|
62
|
+
if year not in grouped:
|
|
63
|
+
grouped[year] = []
|
|
64
|
+
grouped[year].append(consumption)
|
|
65
|
+
|
|
66
|
+
result = {}
|
|
67
|
+
|
|
68
|
+
for year, values in grouped.items():
|
|
69
|
+
result[year] = max(values)
|
|
70
|
+
|
|
71
|
+
print("Output:")
|
|
72
|
+
for year, maximum in result.items():
|
|
73
|
+
print(year, maximum)
|
|
74
|
+
""",
|
|
75
|
+
"3": """# 3) MapReduce Program to Analyse Weather Dataset and Print Whether the Day is Sunny or Cool
|
|
76
|
+
|
|
77
|
+
n = int(input("Enter number of records: "))
|
|
78
|
+
data = []
|
|
79
|
+
|
|
80
|
+
print("Enter Date City Temperature:")
|
|
81
|
+
for i in range(n):
|
|
82
|
+
data.append(input().split())
|
|
83
|
+
|
|
84
|
+
mapped = []
|
|
85
|
+
|
|
86
|
+
for record in data:
|
|
87
|
+
date = record[0]
|
|
88
|
+
city = record[1]
|
|
89
|
+
temperature = int(record[2])
|
|
90
|
+
|
|
91
|
+
if temperature >= 30:
|
|
92
|
+
status = "Sunny"
|
|
93
|
+
else:
|
|
94
|
+
status = "Cool"
|
|
95
|
+
|
|
96
|
+
mapped.append((date + " " + city, status))
|
|
97
|
+
|
|
98
|
+
grouped = {}
|
|
99
|
+
|
|
100
|
+
for key, value in mapped:
|
|
101
|
+
if key not in grouped:
|
|
102
|
+
grouped[key] = []
|
|
103
|
+
grouped[key].append(value)
|
|
104
|
+
|
|
105
|
+
result = {}
|
|
106
|
+
|
|
107
|
+
for key, values in grouped.items():
|
|
108
|
+
result[key] = values[0]
|
|
109
|
+
|
|
110
|
+
print("Output:")
|
|
111
|
+
for key, value in result.items():
|
|
112
|
+
print(key, value)
|
|
113
|
+
""",
|
|
114
|
+
"4": """# 4) MapReduce Program to Find the Tags Associated with Each Movie by Analyzing MovieLens Data
|
|
115
|
+
|
|
116
|
+
n = int(input("Enter number of records: "))
|
|
117
|
+
data = []
|
|
118
|
+
|
|
119
|
+
print("Enter UserID,MovieID,Tag:")
|
|
120
|
+
for i in range(n):
|
|
121
|
+
data.append(input().split(","))
|
|
122
|
+
|
|
123
|
+
mapped = []
|
|
124
|
+
|
|
125
|
+
for record in data:
|
|
126
|
+
movie_id = record[1]
|
|
127
|
+
tag = record[2]
|
|
128
|
+
mapped.append((movie_id, tag))
|
|
129
|
+
|
|
130
|
+
grouped = {}
|
|
131
|
+
|
|
132
|
+
for movie_id, tag in mapped:
|
|
133
|
+
if movie_id not in grouped:
|
|
134
|
+
grouped[movie_id] = []
|
|
135
|
+
grouped[movie_id].append(tag)
|
|
136
|
+
|
|
137
|
+
result = {}
|
|
138
|
+
|
|
139
|
+
for movie_id, tags in grouped.items():
|
|
140
|
+
result[movie_id] = ", ".join(tags)
|
|
141
|
+
|
|
142
|
+
print("Output:")
|
|
143
|
+
for movie_id, tags in result.items():
|
|
144
|
+
print(movie_id, tags)
|
|
145
|
+
""",
|
|
146
|
+
"5": """# 5) K-Means Clustering Algorithm Using MapReduce
|
|
147
|
+
|
|
148
|
+
n = int(input("Enter number of points: "))
|
|
149
|
+
points = []
|
|
150
|
+
|
|
151
|
+
print("Enter X,Y:")
|
|
152
|
+
for i in range(n):
|
|
153
|
+
points.append(list(map(int, input().split(","))))
|
|
154
|
+
|
|
155
|
+
c1x, c1y = map(int, input("Enter Centroid 1 X,Y: ").split(","))
|
|
156
|
+
c2x, c2y = map(int, input("Enter Centroid 2 X,Y: ").split(","))
|
|
157
|
+
|
|
158
|
+
mapped = []
|
|
159
|
+
|
|
160
|
+
for x, y in points:
|
|
161
|
+
d1 = ((x - c1x) ** 2 + (y - c1y) ** 2) ** 0.5
|
|
162
|
+
d2 = ((x - c2x) ** 2 + (y - c2y) ** 2) ** 0.5
|
|
163
|
+
|
|
164
|
+
if d1 < d2:
|
|
165
|
+
mapped.append(("Cluster1", (x, y)))
|
|
166
|
+
else:
|
|
167
|
+
mapped.append(("Cluster2", (x, y)))
|
|
168
|
+
|
|
169
|
+
grouped = {}
|
|
170
|
+
|
|
171
|
+
for cluster, point in mapped:
|
|
172
|
+
if cluster not in grouped:
|
|
173
|
+
grouped[cluster] = []
|
|
174
|
+
grouped[cluster].append(point)
|
|
175
|
+
|
|
176
|
+
result = {}
|
|
177
|
+
|
|
178
|
+
for cluster, cluster_points in grouped.items():
|
|
179
|
+
sum_x = 0
|
|
180
|
+
sum_y = 0
|
|
181
|
+
|
|
182
|
+
for x, y in cluster_points:
|
|
183
|
+
sum_x += x
|
|
184
|
+
sum_y += y
|
|
185
|
+
|
|
186
|
+
centroid_x = sum_x // len(cluster_points)
|
|
187
|
+
centroid_y = sum_y // len(cluster_points)
|
|
188
|
+
|
|
189
|
+
result[cluster] = (centroid_x, centroid_y)
|
|
190
|
+
|
|
191
|
+
print("Output:")
|
|
192
|
+
for cluster, centroid in result.items():
|
|
193
|
+
print(cluster, centroid)
|
|
194
|
+
"""
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
TITLES = {
|
|
198
|
+
"1": "MapReduce Program to Implement Matrix Multiplication",
|
|
199
|
+
"2": "MapReduce Program to Find the Maximum Electrical Consumption in Each Year",
|
|
200
|
+
"3": "MapReduce Program to Analyse Weather Dataset and Print Whether the Day is Sunny or Cool",
|
|
201
|
+
"4": "MapReduce Program to Find the Tags Associated with Each Movie by Analyzing MovieLens Data",
|
|
202
|
+
"5": "K-Means Clustering Algorithm Using MapReduce",
|
|
203
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: matplotlid
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Custom MapReduce programs viewer package
|
|
5
|
+
Author: Custom Developer
|
|
6
|
+
Requires-Python: >=3.6
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Dynamic: author
|
|
9
|
+
Dynamic: requires-python
|
|
10
|
+
|
|
11
|
+
# Custom `matplotlid` MapReduce Programs Package
|
|
12
|
+
|
|
13
|
+
This custom library allows you to view MapReduce programs directly in your terminal using commands like `py -m matplotlid 1` or `python -m matplotlid 1`.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
To install this package into your Python environment:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Navigate to the project directory
|
|
21
|
+
cd /Users/a1989/.gemini/antigravity-ide/scratch/matplotlid
|
|
22
|
+
|
|
23
|
+
# Install in editable mode
|
|
24
|
+
py -m pip install -e .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or install using standard `pip`:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Run any of the following commands in your terminal:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
py -m matplotlid 1
|
|
39
|
+
py -m matplotlid 2
|
|
40
|
+
py -m matplotlid 3
|
|
41
|
+
py -m matplotlid 4
|
|
42
|
+
py -m matplotlid 5
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Running without a number shows the list of available programs:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
py -m matplotlid
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## List of Included Programs
|
|
52
|
+
|
|
53
|
+
1. **MapReduce Program to Implement Matrix Multiplication** (`py -m matplotlid 1`)
|
|
54
|
+
2. **MapReduce Program to Find the Maximum Electrical Consumption in Each Year** (`py -m matplotlid 2`)
|
|
55
|
+
3. **MapReduce Program to Analyse Weather Dataset and Print Whether the Day is Sunny or Cool** (`py -m matplotlid 3`)
|
|
56
|
+
4. **MapReduce Program to Find the Tags Associated with Each Movie by Analyzing MovieLens Data** (`py -m matplotlid 4`)
|
|
57
|
+
5. **K-Means Clustering Algorithm Using MapReduce** (`py -m matplotlid 5`)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
matplotlid/__init__.py,sha256=nVLOBvF3DC8AV3w720Uvi9K0ePfvpNNMWi5jHagVJy8,168
|
|
2
|
+
matplotlid/__main__.py,sha256=jehO6NRUdP8u6eQceQdK53ZDxZz56V15pmmYnSeeajE,713
|
|
3
|
+
matplotlid/programs.py,sha256=KaLqPuC5K4A5-R-iszxUDw_72AbYHK8g1fxfqGPAPRo,4598
|
|
4
|
+
matplotlid-1.0.0.dist-info/METADATA,sha256=AD7NpYi2a3ddPIdbZhu9HhJLRIXV8paUCFZcHTsLyzQ,1526
|
|
5
|
+
matplotlid-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
matplotlid-1.0.0.dist-info/top_level.txt,sha256=oU8JuiRYdswvhH7q8mmkRytYT8Ksto7Bl8Sl6oCtKyE,11
|
|
7
|
+
matplotlid-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
matplotlid
|