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

SVC predict_proba not supported #46

Closed IslamSabdelazez closed 5 years ago

IslamSabdelazez commented 5 years ago

when i try to export "porter = Porter(model, language='java', method= 'predict_proba')" from SVC model it returns "Currently the chosen model method 'predict_proba' isn't supported." is there any solution to get the probability of the predicted class ?!

nok commented 5 years ago

Sorry, not today, this feature is work in progress.

lunar74 commented 5 years ago

When will you release this feature? I need this, too.

KMKnation commented 5 years ago

Any new updates? on this feature.

nok commented 5 years ago

Hello @KMKnation , yes, the adaption of all listed estimators is still in progress.

nok commented 5 years ago

The estimator sklearn.svm.SVC doesn't support the computation of the class probabilities. There is no predict_proba mehtod. Because of that there will be no implementation in sklearn-porter.

D-Chen33 commented 4 years ago

Hi Nok,

Thanks for the project.

I think sklearn.svm.SVC is supporting class probabilities, as shown in this link:

https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC.predict_proba

I wonder if you can include it :-)

ghost commented 4 years ago

This feature is much required please update.

AmirHosseinCV commented 3 years ago

I needed the same thing for RandomForestClassifier, I changed the last part of code (in my case, js code):

this.predict = function(features) {
        var classes = new Array(3).fill(0);
        for (var i = 0; i < trees.length; i++) {
            classes[trees[i](features)]++;
        }
        return findMax(classes);
}

to:

this.predict = function(features) {
        var classes = new Array(3).fill(0);
        for (var i = 0; i < trees.length; i++) {
            classes[trees[i](features)]++;
        }
        return classes;
}

But I don't know if it works with svm or not.