iotml 0.1.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.
- iotml-0.1.0/LICENSE +21 -0
- iotml-0.1.0/PKG-INFO +75 -0
- iotml-0.1.0/README.md +59 -0
- iotml-0.1.0/iotml/__init__.py +32 -0
- iotml-0.1.0/iotml/__main__.py +4 -0
- iotml-0.1.0/iotml/main.py +421 -0
- iotml-0.1.0/iotml.egg-info/PKG-INFO +75 -0
- iotml-0.1.0/iotml.egg-info/SOURCES.txt +12 -0
- iotml-0.1.0/iotml.egg-info/dependency_links.txt +1 -0
- iotml-0.1.0/iotml.egg-info/entry_points.txt +2 -0
- iotml-0.1.0/iotml.egg-info/requires.txt +4 -0
- iotml-0.1.0/iotml.egg-info/top_level.txt +1 -0
- iotml-0.1.0/pyproject.toml +28 -0
- iotml-0.1.0/setup.cfg +4 -0
iotml-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Meena
|
|
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.
|
iotml-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iotml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: IoT & Data Analytics Lab toolkit for live API fetching, visualization, and ML models
|
|
5
|
+
Author: Meena
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: iot,machine-learning,analytics,iss,earthquake,weather,air-quality
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: requests
|
|
12
|
+
Requires-Dist: pandas
|
|
13
|
+
Requires-Dist: matplotlib
|
|
14
|
+
Requires-Dist: scikit-learn
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# iotml
|
|
18
|
+
|
|
19
|
+
**IoT & Data Analytics Lab Toolkit** — Live API sensor data analysis, time-series visualizations, and machine learning models in one simple command.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ⚡ Super Short Commands
|
|
24
|
+
|
|
25
|
+
### 1. Install
|
|
26
|
+
```bash
|
|
27
|
+
pip install iotml
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Run
|
|
31
|
+
```bash
|
|
32
|
+
iotml
|
|
33
|
+
```
|
|
34
|
+
*(Or run with `python -m iotml`)*
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 📦 Features & Menu Options
|
|
39
|
+
|
|
40
|
+
1. **ISS Location Tracker**: Live stream of ISS coordinates & trajectory plots.
|
|
41
|
+
2. **Earthquake Analysis**: Real-time seismic event analysis from USGS.
|
|
42
|
+
3. **Weather Analysis**: Live meteorological telemetry from Open-Meteo.
|
|
43
|
+
4. **Air Quality Analysis**: Real-time PM2.5, PM10, and US AQI statistics & graphs.
|
|
44
|
+
5. **Decision Tree**: Sensor occupancy classifier.
|
|
45
|
+
6. **Linear Regression**: Environmental temperature predictor.
|
|
46
|
+
7. **Random Forest**: Multiclass AQI category classification.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🐍 Python Import Usage
|
|
51
|
+
|
|
52
|
+
You can also import functions directly into your scripts or notebooks:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from iotml import (
|
|
56
|
+
analyze_data,
|
|
57
|
+
time_series,
|
|
58
|
+
bar_chart,
|
|
59
|
+
iss_data,
|
|
60
|
+
earthquake_data,
|
|
61
|
+
weather_data,
|
|
62
|
+
air_quality,
|
|
63
|
+
decision_tree,
|
|
64
|
+
linear_regression,
|
|
65
|
+
random_forest
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Example: Run live earthquake analysis
|
|
69
|
+
earthquake_data()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 📄 License
|
|
75
|
+
MIT License
|
iotml-0.1.0/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# iotml
|
|
2
|
+
|
|
3
|
+
**IoT & Data Analytics Lab Toolkit** — Live API sensor data analysis, time-series visualizations, and machine learning models in one simple command.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚡ Super Short Commands
|
|
8
|
+
|
|
9
|
+
### 1. Install
|
|
10
|
+
```bash
|
|
11
|
+
pip install iotml
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### 2. Run
|
|
15
|
+
```bash
|
|
16
|
+
iotml
|
|
17
|
+
```
|
|
18
|
+
*(Or run with `python -m iotml`)*
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📦 Features & Menu Options
|
|
23
|
+
|
|
24
|
+
1. **ISS Location Tracker**: Live stream of ISS coordinates & trajectory plots.
|
|
25
|
+
2. **Earthquake Analysis**: Real-time seismic event analysis from USGS.
|
|
26
|
+
3. **Weather Analysis**: Live meteorological telemetry from Open-Meteo.
|
|
27
|
+
4. **Air Quality Analysis**: Real-time PM2.5, PM10, and US AQI statistics & graphs.
|
|
28
|
+
5. **Decision Tree**: Sensor occupancy classifier.
|
|
29
|
+
6. **Linear Regression**: Environmental temperature predictor.
|
|
30
|
+
7. **Random Forest**: Multiclass AQI category classification.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🐍 Python Import Usage
|
|
35
|
+
|
|
36
|
+
You can also import functions directly into your scripts or notebooks:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from iotml import (
|
|
40
|
+
analyze_data,
|
|
41
|
+
time_series,
|
|
42
|
+
bar_chart,
|
|
43
|
+
iss_data,
|
|
44
|
+
earthquake_data,
|
|
45
|
+
weather_data,
|
|
46
|
+
air_quality,
|
|
47
|
+
decision_tree,
|
|
48
|
+
linear_regression,
|
|
49
|
+
random_forest
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Example: Run live earthquake analysis
|
|
53
|
+
earthquake_data()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 📄 License
|
|
59
|
+
MIT License
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
iotml: IoT & Data Analytics Lab toolkit.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .main import (
|
|
6
|
+
analyze_data,
|
|
7
|
+
time_series,
|
|
8
|
+
bar_chart,
|
|
9
|
+
iss_data,
|
|
10
|
+
earthquake_data,
|
|
11
|
+
weather_data,
|
|
12
|
+
air_quality,
|
|
13
|
+
decision_tree,
|
|
14
|
+
linear_regression,
|
|
15
|
+
random_forest,
|
|
16
|
+
main,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
__version__ = "0.1.0"
|
|
20
|
+
__all__ = [
|
|
21
|
+
"analyze_data",
|
|
22
|
+
"time_series",
|
|
23
|
+
"bar_chart",
|
|
24
|
+
"iss_data",
|
|
25
|
+
"earthquake_data",
|
|
26
|
+
"weather_data",
|
|
27
|
+
"air_quality",
|
|
28
|
+
"decision_tree",
|
|
29
|
+
"linear_regression",
|
|
30
|
+
"random_forest",
|
|
31
|
+
"main",
|
|
32
|
+
]
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
|
|
5
|
+
from sklearn.model_selection import train_test_split
|
|
6
|
+
from sklearn.tree import DecisionTreeClassifier
|
|
7
|
+
from sklearn.ensemble import RandomForestClassifier
|
|
8
|
+
from sklearn.linear_model import LinearRegression
|
|
9
|
+
from sklearn.metrics import accuracy_score, confusion_matrix, mean_squared_error, r2_score
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# -------------------------------------------------
|
|
13
|
+
# 1. BASIC DATA ANALYSIS FUNCTION
|
|
14
|
+
# -------------------------------------------------
|
|
15
|
+
|
|
16
|
+
def analyze_data(df):
|
|
17
|
+
print("\n========== DATA ==========")
|
|
18
|
+
print(df.head())
|
|
19
|
+
|
|
20
|
+
print("\n========== STATISTICS ==========")
|
|
21
|
+
print(df.describe())
|
|
22
|
+
|
|
23
|
+
print("\n========== NULL VALUES ==========")
|
|
24
|
+
print(df.isnull().sum())
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# -------------------------------------------------
|
|
28
|
+
# 2. TIME SERIES PLOT
|
|
29
|
+
# -------------------------------------------------
|
|
30
|
+
|
|
31
|
+
def time_series(df, x, y):
|
|
32
|
+
plt.figure(figsize=(8, 4))
|
|
33
|
+
plt.plot(df[x], df[y])
|
|
34
|
+
plt.xlabel(x)
|
|
35
|
+
plt.ylabel(y)
|
|
36
|
+
plt.title(y + " vs " + x)
|
|
37
|
+
plt.xticks(rotation=45)
|
|
38
|
+
plt.tight_layout()
|
|
39
|
+
plt.show()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# -------------------------------------------------
|
|
43
|
+
# 3. BAR CHART
|
|
44
|
+
# -------------------------------------------------
|
|
45
|
+
|
|
46
|
+
def bar_chart(df, x, y):
|
|
47
|
+
plt.figure(figsize=(8, 4))
|
|
48
|
+
plt.bar(df[x], df[y])
|
|
49
|
+
plt.xlabel(x)
|
|
50
|
+
plt.ylabel(y)
|
|
51
|
+
plt.title(y + " Bar Chart")
|
|
52
|
+
plt.xticks(rotation=45)
|
|
53
|
+
plt.tight_layout()
|
|
54
|
+
plt.show()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# -------------------------------------------------
|
|
58
|
+
# 4. ISS LOCATION
|
|
59
|
+
# -------------------------------------------------
|
|
60
|
+
|
|
61
|
+
def iss_data():
|
|
62
|
+
|
|
63
|
+
url = "http://api.open-notify.org/iss-now.json"
|
|
64
|
+
|
|
65
|
+
records = []
|
|
66
|
+
|
|
67
|
+
for i in range(10): # change to 100 for assignment
|
|
68
|
+
response = requests.get(url)
|
|
69
|
+
data = response.json()
|
|
70
|
+
|
|
71
|
+
latitude = float(data["iss_position"]["latitude"])
|
|
72
|
+
longitude = float(data["iss_position"]["longitude"])
|
|
73
|
+
|
|
74
|
+
records.append([i + 1, latitude, longitude])
|
|
75
|
+
|
|
76
|
+
df = pd.DataFrame(records,
|
|
77
|
+
columns=["Time", "Latitude", "Longitude"])
|
|
78
|
+
|
|
79
|
+
df.to_csv("iss_data.csv", index=False)
|
|
80
|
+
|
|
81
|
+
print("\nISS Data")
|
|
82
|
+
print(df)
|
|
83
|
+
|
|
84
|
+
time_series(df, "Time", "Latitude")
|
|
85
|
+
time_series(df, "Time", "Longitude")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# -------------------------------------------------
|
|
89
|
+
# 5. EARTHQUAKE DATA
|
|
90
|
+
# -------------------------------------------------
|
|
91
|
+
|
|
92
|
+
def earthquake_data():
|
|
93
|
+
|
|
94
|
+
url = "https://earthquake.usgs.gov/fdsnws/event/1/query"
|
|
95
|
+
|
|
96
|
+
params = {
|
|
97
|
+
"format": "geojson",
|
|
98
|
+
"starttime": "2026-08-07",
|
|
99
|
+
"endtime": "2026-09-25",
|
|
100
|
+
"minmagnitude": 2.5,
|
|
101
|
+
"orderby": "time"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
response = requests.get(url, params=params)
|
|
105
|
+
data = response.json()
|
|
106
|
+
|
|
107
|
+
records = []
|
|
108
|
+
|
|
109
|
+
for earthquake in data["features"]:
|
|
110
|
+
|
|
111
|
+
p = earthquake["properties"]
|
|
112
|
+
c = earthquake["geometry"]["coordinates"]
|
|
113
|
+
|
|
114
|
+
records.append([
|
|
115
|
+
p["mag"],
|
|
116
|
+
p["place"],
|
|
117
|
+
pd.to_datetime(p["time"], unit="ms"),
|
|
118
|
+
c[0],
|
|
119
|
+
c[1],
|
|
120
|
+
c[2],
|
|
121
|
+
p["tsunami"]
|
|
122
|
+
])
|
|
123
|
+
|
|
124
|
+
df = pd.DataFrame(records,
|
|
125
|
+
columns=[
|
|
126
|
+
"Magnitude",
|
|
127
|
+
"Place",
|
|
128
|
+
"Time",
|
|
129
|
+
"Longitude",
|
|
130
|
+
"Latitude",
|
|
131
|
+
"Depth",
|
|
132
|
+
"Tsunami"
|
|
133
|
+
])
|
|
134
|
+
|
|
135
|
+
df.to_csv("earthquake.csv", index=False)
|
|
136
|
+
|
|
137
|
+
analyze_data(df)
|
|
138
|
+
|
|
139
|
+
plt.figure(figsize=(8, 4))
|
|
140
|
+
plt.plot(df["Time"], df["Magnitude"])
|
|
141
|
+
plt.xlabel("Time")
|
|
142
|
+
plt.ylabel("Magnitude")
|
|
143
|
+
plt.title("Earthquake Magnitude vs Time")
|
|
144
|
+
plt.xticks(rotation=45)
|
|
145
|
+
plt.tight_layout()
|
|
146
|
+
plt.show()
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# -------------------------------------------------
|
|
150
|
+
# 6. WEATHER DATA
|
|
151
|
+
# -------------------------------------------------
|
|
152
|
+
|
|
153
|
+
def weather_data():
|
|
154
|
+
|
|
155
|
+
url = "https://api.open-meteo.com/v1/forecast"
|
|
156
|
+
|
|
157
|
+
params = {
|
|
158
|
+
"latitude": 9.93,
|
|
159
|
+
"longitude": 76.27,
|
|
160
|
+
"current": "temperature_2m,relative_humidity_2m,wind_speed_10m"
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
response = requests.get(url, params=params)
|
|
164
|
+
data = response.json()
|
|
165
|
+
|
|
166
|
+
print("\n========== WEATHER ==========")
|
|
167
|
+
|
|
168
|
+
print("Temperature:",
|
|
169
|
+
data["current"]["temperature_2m"])
|
|
170
|
+
|
|
171
|
+
print("Humidity:",
|
|
172
|
+
data["current"]["relative_humidity_2m"])
|
|
173
|
+
|
|
174
|
+
print("Wind Speed:",
|
|
175
|
+
data["current"]["wind_speed_10m"])
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# -------------------------------------------------
|
|
179
|
+
# 7. AIR QUALITY DATA
|
|
180
|
+
# -------------------------------------------------
|
|
181
|
+
|
|
182
|
+
def air_quality():
|
|
183
|
+
|
|
184
|
+
url = "https://air-quality-api.open-meteo.com/v1/air-quality"
|
|
185
|
+
|
|
186
|
+
params = {
|
|
187
|
+
"latitude": 9.93,
|
|
188
|
+
"longitude": 76.27,
|
|
189
|
+
"hourly": "pm10,pm2_5,us_aqi",
|
|
190
|
+
"timezone": "auto"
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
response = requests.get(url, params=params)
|
|
194
|
+
data = response.json()
|
|
195
|
+
|
|
196
|
+
df = pd.DataFrame({
|
|
197
|
+
"Time": data["hourly"]["time"],
|
|
198
|
+
"PM10": data["hourly"]["pm10"],
|
|
199
|
+
"PM2.5": data["hourly"]["pm2_5"],
|
|
200
|
+
"AQI": data["hourly"]["us_aqi"]
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
print("\n========== AIR QUALITY ==========")
|
|
204
|
+
print(df.head())
|
|
205
|
+
|
|
206
|
+
print("\nStatistics")
|
|
207
|
+
print(df.describe())
|
|
208
|
+
|
|
209
|
+
plt.figure(figsize=(8, 4))
|
|
210
|
+
plt.plot(df["Time"], df["PM2.5"])
|
|
211
|
+
plt.xlabel("Time")
|
|
212
|
+
plt.ylabel("PM2.5")
|
|
213
|
+
plt.title("PM2.5 vs Time")
|
|
214
|
+
plt.xticks(rotation=45)
|
|
215
|
+
plt.tight_layout()
|
|
216
|
+
plt.show()
|
|
217
|
+
|
|
218
|
+
plt.figure(figsize=(8, 4))
|
|
219
|
+
plt.plot(df["Time"], df["AQI"])
|
|
220
|
+
plt.xlabel("Time")
|
|
221
|
+
plt.ylabel("AQI")
|
|
222
|
+
plt.title("AQI vs Time")
|
|
223
|
+
plt.xticks(rotation=45)
|
|
224
|
+
plt.tight_layout()
|
|
225
|
+
plt.show()
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
# -------------------------------------------------
|
|
229
|
+
# 8. DECISION TREE
|
|
230
|
+
# -------------------------------------------------
|
|
231
|
+
|
|
232
|
+
def decision_tree():
|
|
233
|
+
|
|
234
|
+
# Example sensor data
|
|
235
|
+
data = {
|
|
236
|
+
"Temperature": [23, 25, 30, 22, 28, 24, 31, 21],
|
|
237
|
+
"Humidity": [40, 45, 60, 35, 55, 42, 65, 30],
|
|
238
|
+
"Light": [100, 200, 500, 50, 400, 150, 600, 30],
|
|
239
|
+
"CO2": [500, 600, 1000, 450, 900, 550, 1100, 400],
|
|
240
|
+
"Occupancy": [0, 0, 1, 0, 1, 0, 1, 0]
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
df = pd.DataFrame(data)
|
|
244
|
+
|
|
245
|
+
X = df[["Temperature", "Humidity", "Light", "CO2"]]
|
|
246
|
+
y = df["Occupancy"]
|
|
247
|
+
|
|
248
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
249
|
+
X, y, test_size=0.25, random_state=42
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
model = DecisionTreeClassifier()
|
|
253
|
+
|
|
254
|
+
model.fit(X_train, y_train)
|
|
255
|
+
|
|
256
|
+
prediction = model.predict(X_test)
|
|
257
|
+
|
|
258
|
+
print("\n========== DECISION TREE ==========")
|
|
259
|
+
print("Accuracy:",
|
|
260
|
+
accuracy_score(y_test, prediction))
|
|
261
|
+
|
|
262
|
+
print("\nConfusion Matrix:")
|
|
263
|
+
print(confusion_matrix(y_test, prediction))
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
# -------------------------------------------------
|
|
267
|
+
# 9. LINEAR REGRESSION
|
|
268
|
+
# -------------------------------------------------
|
|
269
|
+
|
|
270
|
+
def linear_regression():
|
|
271
|
+
|
|
272
|
+
data = {
|
|
273
|
+
"PM2.5": [20, 30, 40, 50, 60, 70, 80, 90],
|
|
274
|
+
"PM10": [30, 40, 50, 60, 70, 80, 90, 100],
|
|
275
|
+
"Pressure": [1010, 1008, 1005, 1003, 1000, 998, 995, 993],
|
|
276
|
+
"Dew": [10, 12, 14, 15, 17, 18, 20, 22],
|
|
277
|
+
"Wind": [2, 3, 4, 5, 3, 2, 4, 5],
|
|
278
|
+
"Temperature": [15, 17, 20, 22, 25, 27, 29, 31]
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
df = pd.DataFrame(data)
|
|
282
|
+
|
|
283
|
+
X = df[["PM2.5", "PM10", "Pressure", "Dew", "Wind"]]
|
|
284
|
+
y = df["Temperature"]
|
|
285
|
+
|
|
286
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
287
|
+
X, y, test_size=0.25, random_state=42
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
model = LinearRegression()
|
|
291
|
+
|
|
292
|
+
model.fit(X_train, y_train)
|
|
293
|
+
|
|
294
|
+
prediction = model.predict(X_test)
|
|
295
|
+
|
|
296
|
+
print("\n========== LINEAR REGRESSION ==========")
|
|
297
|
+
|
|
298
|
+
print("MSE:",
|
|
299
|
+
mean_squared_error(y_test, prediction))
|
|
300
|
+
|
|
301
|
+
print("R2 Score:",
|
|
302
|
+
r2_score(y_test, prediction))
|
|
303
|
+
|
|
304
|
+
# New sensor reading
|
|
305
|
+
new_data = [[50, 60, 1000, 15, 3]]
|
|
306
|
+
|
|
307
|
+
result = model.predict(new_data)
|
|
308
|
+
|
|
309
|
+
print("Predicted Temperature:",
|
|
310
|
+
result[0])
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
# -------------------------------------------------
|
|
314
|
+
# 10. RANDOM FOREST
|
|
315
|
+
# -------------------------------------------------
|
|
316
|
+
|
|
317
|
+
def random_forest():
|
|
318
|
+
|
|
319
|
+
data = {
|
|
320
|
+
"PM2.5": [20, 40, 60, 80, 100, 120, 150, 180],
|
|
321
|
+
"PM10": [30, 50, 70, 90, 110, 130, 160, 200],
|
|
322
|
+
"NO2": [10, 20, 30, 40, 50, 60, 70, 80],
|
|
323
|
+
"CO": [1, 2, 3, 4, 5, 6, 7, 8],
|
|
324
|
+
"SO2": [5, 10, 15, 20, 25, 30, 35, 40],
|
|
325
|
+
"O3": [20, 30, 40, 50, 60, 70, 80, 90],
|
|
326
|
+
"AQI_Category": [
|
|
327
|
+
"Good",
|
|
328
|
+
"Good",
|
|
329
|
+
"Satisfactory",
|
|
330
|
+
"Moderate",
|
|
331
|
+
"Poor",
|
|
332
|
+
"Very Poor",
|
|
333
|
+
"Severe",
|
|
334
|
+
"Severe"
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
df = pd.DataFrame(data)
|
|
339
|
+
|
|
340
|
+
X = df[["PM2.5", "PM10", "NO2", "CO", "SO2", "O3"]]
|
|
341
|
+
y = df["AQI_Category"]
|
|
342
|
+
|
|
343
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
344
|
+
X, y, test_size=0.25, random_state=42
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
model = RandomForestClassifier(
|
|
348
|
+
n_estimators=100,
|
|
349
|
+
random_state=42
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
model.fit(X_train, y_train)
|
|
353
|
+
|
|
354
|
+
prediction = model.predict(X_test)
|
|
355
|
+
|
|
356
|
+
print("\n========== RANDOM FOREST ==========")
|
|
357
|
+
|
|
358
|
+
print("Accuracy:",
|
|
359
|
+
accuracy_score(y_test, prediction))
|
|
360
|
+
|
|
361
|
+
print("\nConfusion Matrix:")
|
|
362
|
+
print(confusion_matrix(y_test, prediction))
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
# -------------------------------------------------
|
|
366
|
+
# MAIN MENU
|
|
367
|
+
# -------------------------------------------------
|
|
368
|
+
|
|
369
|
+
def main():
|
|
370
|
+
while True:
|
|
371
|
+
|
|
372
|
+
print("\n================================")
|
|
373
|
+
print(" DATA ANALYTICS LAB")
|
|
374
|
+
print("================================")
|
|
375
|
+
|
|
376
|
+
print("1. ISS Location")
|
|
377
|
+
print("2. Earthquake Analysis")
|
|
378
|
+
print("3. Weather Analysis")
|
|
379
|
+
print("4. Air Quality Analysis")
|
|
380
|
+
print("5. Decision Tree")
|
|
381
|
+
print("6. Linear Regression")
|
|
382
|
+
print("7. Random Forest")
|
|
383
|
+
print("8. Exit")
|
|
384
|
+
|
|
385
|
+
try:
|
|
386
|
+
choice = input("\nEnter your choice: ")
|
|
387
|
+
except (KeyboardInterrupt, EOFError):
|
|
388
|
+
print("\nProgram ended.")
|
|
389
|
+
break
|
|
390
|
+
|
|
391
|
+
if choice == "1":
|
|
392
|
+
iss_data()
|
|
393
|
+
|
|
394
|
+
elif choice == "2":
|
|
395
|
+
earthquake_data()
|
|
396
|
+
|
|
397
|
+
elif choice == "3":
|
|
398
|
+
weather_data()
|
|
399
|
+
|
|
400
|
+
elif choice == "4":
|
|
401
|
+
air_quality()
|
|
402
|
+
|
|
403
|
+
elif choice == "5":
|
|
404
|
+
decision_tree()
|
|
405
|
+
|
|
406
|
+
elif choice == "6":
|
|
407
|
+
linear_regression()
|
|
408
|
+
|
|
409
|
+
elif choice == "7":
|
|
410
|
+
random_forest()
|
|
411
|
+
|
|
412
|
+
elif choice == "8":
|
|
413
|
+
print("Program ended.")
|
|
414
|
+
break
|
|
415
|
+
|
|
416
|
+
else:
|
|
417
|
+
print("Invalid choice")
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
if __name__ == "__main__":
|
|
421
|
+
main()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iotml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: IoT & Data Analytics Lab toolkit for live API fetching, visualization, and ML models
|
|
5
|
+
Author: Meena
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: iot,machine-learning,analytics,iss,earthquake,weather,air-quality
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: requests
|
|
12
|
+
Requires-Dist: pandas
|
|
13
|
+
Requires-Dist: matplotlib
|
|
14
|
+
Requires-Dist: scikit-learn
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# iotml
|
|
18
|
+
|
|
19
|
+
**IoT & Data Analytics Lab Toolkit** — Live API sensor data analysis, time-series visualizations, and machine learning models in one simple command.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ⚡ Super Short Commands
|
|
24
|
+
|
|
25
|
+
### 1. Install
|
|
26
|
+
```bash
|
|
27
|
+
pip install iotml
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Run
|
|
31
|
+
```bash
|
|
32
|
+
iotml
|
|
33
|
+
```
|
|
34
|
+
*(Or run with `python -m iotml`)*
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 📦 Features & Menu Options
|
|
39
|
+
|
|
40
|
+
1. **ISS Location Tracker**: Live stream of ISS coordinates & trajectory plots.
|
|
41
|
+
2. **Earthquake Analysis**: Real-time seismic event analysis from USGS.
|
|
42
|
+
3. **Weather Analysis**: Live meteorological telemetry from Open-Meteo.
|
|
43
|
+
4. **Air Quality Analysis**: Real-time PM2.5, PM10, and US AQI statistics & graphs.
|
|
44
|
+
5. **Decision Tree**: Sensor occupancy classifier.
|
|
45
|
+
6. **Linear Regression**: Environmental temperature predictor.
|
|
46
|
+
7. **Random Forest**: Multiclass AQI category classification.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🐍 Python Import Usage
|
|
51
|
+
|
|
52
|
+
You can also import functions directly into your scripts or notebooks:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from iotml import (
|
|
56
|
+
analyze_data,
|
|
57
|
+
time_series,
|
|
58
|
+
bar_chart,
|
|
59
|
+
iss_data,
|
|
60
|
+
earthquake_data,
|
|
61
|
+
weather_data,
|
|
62
|
+
air_quality,
|
|
63
|
+
decision_tree,
|
|
64
|
+
linear_regression,
|
|
65
|
+
random_forest
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Example: Run live earthquake analysis
|
|
69
|
+
earthquake_data()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 📄 License
|
|
75
|
+
MIT License
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
iotml/__init__.py
|
|
5
|
+
iotml/__main__.py
|
|
6
|
+
iotml/main.py
|
|
7
|
+
iotml.egg-info/PKG-INFO
|
|
8
|
+
iotml.egg-info/SOURCES.txt
|
|
9
|
+
iotml.egg-info/dependency_links.txt
|
|
10
|
+
iotml.egg-info/entry_points.txt
|
|
11
|
+
iotml.egg-info/requires.txt
|
|
12
|
+
iotml.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
iotml
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "iotml"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "IoT & Data Analytics Lab toolkit for live API fetching, visualization, and ML models"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Meena"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["iot", "machine-learning", "analytics", "iss", "earthquake", "weather", "air-quality"]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"requests",
|
|
18
|
+
"pandas",
|
|
19
|
+
"matplotlib",
|
|
20
|
+
"scikit-learn",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
iotml = "iotml.main:main"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.packages.find]
|
|
27
|
+
where = ["."]
|
|
28
|
+
include = ["iotml*"]
|
iotml-0.1.0/setup.cfg
ADDED