nok / sklearn-porter

Transpile trained scikit-learn estimators to C, Java, JavaScript and others.
BSD 3-Clause "New" or "Revised" License
1.28k stars 170 forks source link

Generating probabilities instead of categorical results #80

Open tejas9090 opened 3 years ago

tejas9090 commented 3 years ago

1) Is there some way to generate C code which would give me floating point probabilities for every prediction category instead of a binary result? I am using the ExtraTreeModel from sklearn (code snippet shown below).

2) My model is almost 1Gb in size, the C code generated is about the same size, which will take forever to compile, is there a way to compress this model or split up the files?

Training Code Snippet

from sklearn.ensemble import ExtraTreesClassifier
from joblib import dump, load

clf = ExtraTreesClassifier(n_estimators=250, random_state=0,verbose=True)
clf.fit(train_x, train_y)
prob_test_data = clf.predict_proba(test_x)

Thanks in advance