- Are you setting up/programming the devices individually using the Arduino IDE or using MATLAB?
- Are the trained weights different for each channel/device, or the same across all channels?
- Are you training the models from MATLAB on your desktop?
- How often does a retraining happen that triggers an update to the channel metadata?
How to store machine learning models for multiple users - Thingspeak & Matlab
2 views (last 30 days)
Show older comments
Hi all!
I have been using Matlab and Thingspeak for several years. What began as a hobby for personal use is turning into a potential business but I am running into questions about how to scale my application in Thingspeak and Matlab. For example, I am collecting data from a series of Arduino devices, each of which is assigned to a different customer. I need to train a machine learning model for each customer and store the trained weights for each customer - and then apply the weights in real time as new data arrives in Thingspeak.
I have done this successfully for one user - by storing the weights in the Metadata field in a Thingspeak channel. This feels ineffiient however and I'm hoping there is a better way in Thingspeak - an application I am already so familiar and comfortable with.
Also, I have done a lot of experimenting with Amazon AWS but I find it extremely complicated and frankly potentiall quite expensive - so I'm hoping someone else may have tackled this in a similar problem.
Thank you!
Ben
1 Comment
Vinod
on 16 Oct 2019
Ben,
That's great to hear that your hobby is becoming a business.
Coming to your question, some follow on questions for me to point you in the suggested direction:
Vinod
Answers (3)
Ben Alimansky
on 16 Oct 2019
1 Comment
Vinod
on 17 Oct 2019
Hi Ben,
based on what you say, I figure you have the embedded software that goes on the Arduino figured out and your questions are about scaling the MATLAB aspects.
Assuming you are doing the training of the machine learning algorithm and extraction of the weights in MATLAB code, I'd recommend that you modify the same script to use the Channel API to find all all your channels. Then you can iterate over each, pull down data, calculate the weights and upload it to the channel's metadata using the Channel API. So every time you add new devices and calculate weights, your metadata is up to date across all your channels.
As to how to now apply these weights to your data as it comes in, you can use the React App or the TimeControl App on ThingSpeak to execute MATLAB code. If you have multiple channels, I'd recommend the TimeControl app schedule MATLAB code to run at a fixed schedule, maybe every hour, that pulls the raw data for the last hour from the channels the device is sending to, apply the weights and write the "corrected" data to a new channel. Using the Channel API you can iterate over any number of channels you have.
Using the above described approach, you can add and remove devices at will and not have to modify your MATLAB code for the TimeControl or the machine learning.
As for scaling this among many users, you can share the code that you use for both the machine learning and the TimeControl on GitHub (with your user API key replaced by a placeholder, of course) and have each of your users follow a simple copy-paste and change the user API key to reproduce what you have.
Does that address your use case?
-Vinod
Ben Alimansky
on 17 Oct 2019
1 Comment
Vinod
on 17 Oct 2019
Yes, there is a way to programmatically create and delete channels. Refer the API documentation here: https://www.mathworks.com/help/thingspeak/rest-api.html
Specifically, see:
As of now, there is no documented API to create the MATLAB code for a user and the associated TimeControl or React. We're looking into that. If that is the only thing blocking you, we may be able to discuss workarounds.
Communities
More Answers in the ThingSpeak Community
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!