Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import trained scikit-learn model to android project

I am working on classification project in python, which uses scikit-learn library. I am using Random Forest for classification. I am using UCI dataset which have 31 features. I have trained the model and saved final pickled model. Now I have a pickle file and python script for extracting features for future prediction.


Now I want to develop user interface for my trained model in android, how can I import my trained final model and feature_extraction python script in android project. I am using scikit-learn and used anaconda and spyder for developing model.

like image 996
Abhishek Dobhal Avatar asked Nov 18 '22 09:11

Abhishek Dobhal


1 Answers

You have a couple of different options here, though none are very smooth.

A) Embed Python into your Android app

Quite complicated, especially for libraries with native C extensions like scikit-learn. However once the setup is done, you can use any Python code your want. Some tools to simplify the process are available in the Python-for-Android project. https://github.com/kivy/python-for-android Kivy is a GUI framework that allows to write Android apps in pure Python. If you don't already know Java and have an existing app, that might be easiest way to go.

B) Rewrite your ML algorithm in Java For instance using Weka framework and their RandomForests implementation. Once the rewrite is done, integration in an Android app will be pain-free.

like image 150
Jon Nordby Avatar answered Dec 20 '22 11:12

Jon Nordby