Using sklearn in android device - android

I am currently using sklearn doing machine learning for the sensor data I collected from an android device.
But the thing is I need to do predictions after the model is trained. Since there will be lots of sensor data generated in a very short time, doing predicting in a server or some other machine is my last choice.
Then it comes to me that is there a way I could do sklearn in android? I could think of three solutions:
Is it possible to run sklearn in android and just let the sklearn script to do the prediction?
If not 1, is it possible for me to use some intermediate library in java (android) to pick up the model I trained in python?
If not 1 and 2, is it possible for me to use some other machine learning library that is supported in the android platform?

I work on a project that called sklearn-porter which ports trained models to a low level programming language like C, Java and JavaScript. More classifiers and regressors will be added at given time.

Related

Saving/Transmitting Model - TensorFlow Lite Transfer Learning on Android

I am trying to create a pair of Android apps: one which trains an image classification transfer-learning model and one which simply uses the trained model for inference. These apps would run on separate devices, and the usefulness would lie in training the model on a more-powerful device and being able to perform inference with that model on a less-powerful wearable device. Transfer learning is being implemented as explained in the post here: https://blog.tensorflow.org/2019/12/example-on-device-model-personalization.html.
The problem is I cannot find a good way to save and transmit the trained model from the first device to the second. I have tried implementing serialization for Bluetooth transmission, but the Android TFL library is not easy to make serializable. How difficult would it be to somehow save a .tflite file on Android? Does this feature already exist and I have missed it? Any help or ideas would be greatly appreciated. Thank you!
For transferring the model, you should do this as a binary instead of trying to explicitly serialize/deserialize. There are a number of different libraries available for this on Android, so it shouldn't be too difficult to find something that works for your app.
As for loading the TFLite model itself and running inference, it's possible to do this device-local using the TFLite Interpreter class and simply pointing it at your on-device file. You can find an example of this here: https://www.tensorflow.org/lite/inference_with_metadata/lite_support

Creating a simple neural network on Tensorflow by means of Android

I want to create a simple neural network based on the example https://github.com/googlesamples/android-ndk/tree/master/nn_sample. Is it possible to create this with the help on Tensorflow only with Android tools on Java
Take a look at this folder https://github.com/googlesamples/android-ndk/tree/master/nn_sample/app/src/main/cpp
simple_model.h is the model trained in Tensorflow before creating the Android project. Now the model likes black-box, get input and predict output only, if you want to build your own model, try this tutorial (All steps from training, evaluating, prediction to deploy onto Android):
https://medium.com/#elye.project/applying-tensorflow-in-android-in-4-steps-to-recognize-superhero-f224597eb055
Affirmative. You can use TensorFlow Lite on Android, it's an open source deep learning framework which helps to compress and deploy models to a mobile or embedded application. It basically can take models as input and then deploys and interpret and perform resource-conserving optimizations for mobile applications. The NNAPI of Android NDK can interface with TFLite easily too. This link contains gesture, image, object & speech detection and classification example implementations on Android with Java using TFLite.

How to implement machine learning models on mobile phones?

I've built Machine Learning Models Random Forest and XGBOOST on Python or R
How can I implement that my model work in mobile phone IOS / Android? Not for training, just to predict the probability for users by properties and events.
You can expose your machine learning model as a REST API endpoint. Essentially, the client (mobile) will be making requests at a specific endpoint, which will then be triggering your model.
There quite a few examples available in the Web for you to read but for your convenience you may take a look at this one.
I think I'm qualified to answer this because it was yesterday that I viewed Google's "DevFestOnAir 2018". There was an "End to End Machine Learning" talk where the speaker mentioned what TensorFlow(TF) has to support AI in mobile devices.
Now, TF is available for JS , Java and many other languages, so this captures the entirety of the model that runs on your PC, uses other functionalities to make it run on lesser RAM and Processors. Do check this out. If I'm not wrong TF has a feature that would do the conversion for you.

Create an android application like win32 SDK programming

I am new to android programming and I wanted to create an application(vocabulary enhancer/words reminder which I already have for windows ) which pops up at certain time intervals to remind the words I saved earlier.
I thought android programming would be like programming windows which uses visual studio 6 or the latest.
I created a simple hello world program but it involved too many XML and other file references and inclusions.
Is there a way to create applications for android like win32 SDK using which we can create applications for windows. Like createwindows and other straight forward methods instead of having something like mfc or the one android programming uses ?
I have no idea what's "too many XML", other than a great name for a band.
If you're serious in your question, then I suggest you begin here: Comparisons of the Android framework's structure to the MFC/Win32's structure? and work your way forward.
Otherwise, I suggest you do form that band.
There is no equivalent to the Win32 API for Android. The closest you will get would be to talk to the (native) Linux OS. But that will only work if your device is rooted.
And that is the point. Something like the Win32 API would allow an Android app to do things that can interfere with other apps ... and compromise the security of the user's device.

SQLite-sync Sync Framework in Android app

I am working on a project which can sync SQLite on Android app with MySQL on server. At first, my approach is:
-Create a periodic sync service to sync to MySQL via Restful API
-Sync algorithm: http://havrl.blogspot.ie/2013/08/synchronization-algorithm-for.html
-Using Retrofit lib: REST client for Android app.
But I am new to Android and I find it quite difficult to implement this approach. I found another solution: SQLite-sync Synchronization Framework - http://wiki.sqlite-sync.com/projects/sqlite-sync-com-synchronization-tool
This framework is based on Sencha Touch but my project is a native app.
-1: Is there any approaches to use this framework on my project smoothly with the existed SQLite database?
-2: If not, I have to develop sync module from scratch. Is my first approach OK ?
In additional, I have an OCR function on my project which recognize 7-segment number on 7 segment LCD panel using OpenCV. It recognizes well in virtual environment (black-white PC screen) but in actual environment (blood glucose monitor), it doesn't, because of contrast ratio, I thought. So, how can I improve quality of OpenCV 7-segment number recognition ? (contrast,etc) I have no idea of what to do.
you can go by the Sync algorithm you have mentioned in the link - http://havrl.blogspot.ie/2013/08/synchronization-algorithm-for.html
Use Rest APIs within Android sync adapter concept. Highly recommended as it has lot many advantages. Lot of plumbing code can be avoided

Categories

Resources