Benjo :
Currently I am trying to export a model from sklearn to Android. For this I use the library sklearn-porter
(sklearn-porter).
This generates a Java class from the trained model, which looks like the following:
class DecisionTreeClassifier {
public static int predict(double[] features) {
int[] classes = new int[2];
if (features[350] <= 0.5156863033771515) {
if (features[568] <= 0.0019607844296842813) {
if (features[430] <= 0.0019607844296842813) {
if (features[405] <= 0.009803921915590763) {
...
}
This file has a size of about 1 MB and thus the error "Code too large" occurs in Android Studio.
Is there a solution for this problem?
Anne Bierhoff :
When you execute the porter with export_data=True
then you also get a small java class which reads the DecisionTree parameters from a .json
file:
porter = Porter(clf, language='java')
output = porter.export(export_data=True)
print(output)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=305490&siteId=1