nok / sklearn-porter

Transpile trained scikit-learn estimators to C, Java, JavaScript and others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

“Code too large” in Android Studio when using exported sklearn model

Benjoe95 opened this issue · comments

Currently I am trying to export a model from sklearn to Android. For this I use the library sklearn-porter.

I have asked the same question on stackoverflow.
question

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?