Skip to main content

Python library of edge-ml.org: end-to-end machine learning for embedded devices

Project description

Obtain data from edge-ml

from edgeml import DatasetReceiver

1. Create a project

This will also pull the metadata from the server. Here you need the read-key. Make sure there is not trailing / in your URL.

project = DatasetReceiver("https://edge-ml-beta.dmz.teco.edu", "8c051972b56e6b4ad6bd0bf573da580f")
print(project)
Dataset - Name: W_001, ID: 645a255bdd19d537f2a50126, Metadata: {}
Dataset - Name: W_004, ID: 645a255b7d9569d03843a12b, Metadata: {}
Dataset - Name: Square_003, ID: 645a255b2ce253c26b52426c, Metadata: {}
Dataset - Name: Square_004, ID: 645a255b1d6af5e7ed04575f, Metadata: {}
Dataset - Name: Square_002, ID: 645a255bc21261d4cbdc990d, Metadata: {}
Dataset - Name: W_002, ID: 645a255b3ebe0af02b211d5d, Metadata: {}
Dataset - Name: W_003, ID: 645a255b074737af782167e2, Metadata: {}
Dataset - Name: Square_001, ID: 645a255bbacf5ab8ff044304, Metadata: {}
Dataset - Name: edgemlDemo, ID: 64635a79a7a7513e8ac92d32, Metadata: {'langauge': 'python'}
Dataset - Name: edgemlDemo, ID: 64635a7b6fec1d2800b1cd06, Metadata: {'langauge': 'python'}

2. Actually obtain data

Until now, we only have metadata available. We need to pull the actual time-series data using one of the following methods:

We can load the data for a single timeSeries

project.datasets[0].timeSeries[0].loadData()
project.datasets[0].timeSeries[0].data.head()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
time x
0 1970-01-01 00:10:23.339 -823.0
1 1970-01-01 00:10:23.378 -819.0
2 1970-01-01 00:10:23.418 -770.0
3 1970-01-01 00:10:23.458 -746.0
4 1970-01-01 00:10:23.497 -783.0

For a single dataset

project.datasets[0].loadData()
project.datasets[0].data.head()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
time x y z Gestures
0 1970-01-01 00:10:23.339 -823.0 -45.0 4025.0
1 1970-01-01 00:10:23.378 -819.0 -158.0 4075.0
2 1970-01-01 00:10:23.418 -770.0 -255.0 4116.0
3 1970-01-01 00:10:23.458 -746.0 -155.0 4059.0
4 1970-01-01 00:10:23.497 -783.0 -104.0 3963.0

Or for all datasets in the project

project.loadData()
project.data[0].head()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
time x y z Gestures
0 1970-01-01 00:10:23.339 -823.0 -45.0 4025.0
1 1970-01-01 00:10:23.378 -819.0 -158.0 4075.0
2 1970-01-01 00:10:23.418 -770.0 -255.0 4116.0
3 1970-01-01 00:10:23.458 -746.0 -155.0 4059.0
4 1970-01-01 00:10:23.497 -783.0 -104.0 3963.0

Upload data to edge-ml

1. Upload data using timestamps from the device

Here you will need the write-key

from edgeml.edgeml import DatasetCollector
sender = DatasetCollector(url="https://edge-ml-beta.dmz.teco.edu", apiKey="4e6159c9c77124d71f298e93f1ed7254", name="edgemlDemo", useDeviceTime=True, timeSeries=["accX", "accY"], metaData={"langauge": "python"})
import time

for i in range (100):
    await sender.addDataPoint(name="accX", value=i*0.1)
    await sender.addDataPoint(name="accY", value=i*0.5)
    time.sleep(0.01)
sender.onComplete()
True

2. Provide your own timestamps

from edgeml.edgeml import DatasetCollector
sender = DatasetCollector(url="https://edge-ml-beta.dmz.teco.edu", apiKey="4e6159c9c77124d71f298e93f1ed7254", name="edgemlDemo", useDeviceTime=False, timeSeries=["accX", "accY"], metaData={"langauge": "python"})
import time

for i in range (100):
    await sender.addDataPoint(timestamp=i*1000, name="accX", value=i*0.1)
    await sender.addDataPoint(timestamp=i*1000, name="accY", value=i*0.5)
    time.sleep(0.01)
sender.onComplete()
True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edge-ml-0.3.3.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

edge_ml-0.3.3-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page