```python
Project description
from edgeml import edgeml
import time
import math
Globals
READ_KEY = "YOUR_READ_KEY" # Replace with your actual read key
WRITE_KEY = "YOUR_WRITE_KEY" # Replace with your actual write key
BACKEND_URL = "YOUR_BACKEND_URL" # Replace with your actual backend URL
Upload randomly generated data to the server using the edge-ml python library
To upload data to edge-ml, we can use the DatasetCollector
For this, we need to provide the following information:
| Parameter | Description |
|---|---|
url |
The URL to the edge-ml instance. |
write_key |
The API key for writing into the system. |
use_own_timestamps |
If true, users can pass timestamps to the collection function. Otherwise, timestamps are set by the DatasetCollector. |
timeSeries |
An array containing the names of the time series to be used. |
metaData |
A dictionary with metadata. Must contain only key-value pairs where both keys and values are strings. |
datasetName = "Example Dataset"
useOwnTimeStamps = False
timeSeries = ["Acc", "Mag"]
metaData = {}
collector = edgeml.DatasetCollector(BACKEND_URL,
WRITE_KEY,
datasetName,
useOwnTimeStamps,
timeSeries,
metaData)
Now we can add data to this dataset
For this we can call the addDataPoint-function. Don't forget to call onComplete after inserting all the data.
timestamp = round(time.time() * 1000)
for i in range(100):
timestamp += 40
x = i / 10000 # Adjust the divisor to control the frequency of the wave
y_acc = math.sin(x) # Generate the y-coordinate for "Acc"
y_mag = math.cos(x) # Generate the y-coordinate for "Mag"
await collector.addDataPoint(timestamp, "Acc", y_acc)
await collector.addDataPoint(timestamp, "Mag", y_mag)
# signal data collection is complete. This uploads the remaining data to the server
collector.onComplete()
True
Retrieve data from edge-ml
It is also possible to obtain the datasets in a project. To do so use the DatasetReceiver
project = edgeml.DatasetReceiver(BACKEND_URL, READ_KEY)
# See a single dataset
print(project.datasets[0])
# Or get some attribute from the dataset
print(project.datasets[0].metaData)
# Until now, we have only the metdata of the datasets.
# We can also download the actual time-series data.
# Only for one timeSeries:
project.datasets[0].timeSeries[0].loadData()
# Or for one dataset:
project.datasets[0].loadData()
# Or for all datasets:
project.loadData()
Dataset - Name: Example Dataset, ID: 682ee7d8a3130d2327595758, Metadata: {}
{}
Get the data in the dataset
The datasets are provided as pandas dataframes
# Access the data of a dataset
print("Dataset")
print(project.datasets[0].data.head())
print("\nTimeseries")
# Or just one time series
print(project.datasets[0].timeSeries[0].data.head())
# Or get all dataset in a project as list
project_data = project.data
print("\n#datasts: ", len(project_data))
Dataset
time Acc Mag
0 2025-05-22 09:01:12.595 0.0000 1.0
1 2025-05-22 09:01:12.635 0.0001 1.0
2 2025-05-22 09:01:12.675 0.0002 1.0
3 2025-05-22 09:01:12.715 0.0003 1.0
4 2025-05-22 09:01:12.755 0.0004 1.0
Timeseries
time Acc
0 2025-05-22 09:01:12.595 0.0000
1 2025-05-22 09:01:12.635 0.0001
2 2025-05-22 09:01:12.675 0.0002
3 2025-05-22 09:01:12.715 0.0003
4 2025-05-22 09:01:12.755 0.0004
#datasts: 11
Get the labels in the dataset
project.datasets[0].labelings
[]
Labeling in the project
To labelings in a project define the labels
project.labelings
[{'_id': '682f07918245a094a595cdf5',
'name': 'test',
'labels': [{'name': 't1',
'color': '#0081DD',
'_id': '682f07918245a094a595cdf3'},
{'name': 't2', 'color': '#C24A5F', '_id': '682f07918245a094a595cdf4'}],
'projectId': '682ec257f42749f02e3a325f'}]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file edge_ml-0.4.0.tar.gz.
File metadata
- Download URL: edge_ml-0.4.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f8a0cffcf16f8207423d1d27f8e7daaa48cf79b96aaecff117053b0773f4006
|
|
| MD5 |
d791d4509fb96094083f113ca9651114
|
|
| BLAKE2b-256 |
d0b0b4d6bd1031056ff6f763d55aa685db733993a12c469c83dd3d2caafb0965
|
File details
Details for the file edge_ml-0.4.0-py3-none-any.whl.
File metadata
- Download URL: edge_ml-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b43311b3f91b2dcde1a4a1b98cb4ea07679070d1a636fd28f9eca7735aba673
|
|
| MD5 |
7bd54a621ee161dbf6cc9e24eb10fb0d
|
|
| BLAKE2b-256 |
7bd9c1681709e4aac9ab57629056ddc6b6df5668c8d17bff3552fad3d0c7a6e9
|