Mlflow: Proposal:Add the function returning the result of predict_proba() to Model API

Created on 8 Nov 2018  路  4Comments  路  Source: mlflow/mlflow

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Windows10(Docker : Debian GNU/Linux 9)
  • MLflow installed from (source or binary): source
  • MLflow version (run mlflow --version):0.7.0
  • Python version: 3.7.0

Describe the problem

Currently, the serve_model method of mlflow/sklearn.py returns only "model.predict(records)".
I think that there are times when we want to know the classification probability of each class when classifying.
So I suggest adding a function to return "model.predict_proba(records)" results to this method.

Thank you.

enhancement

Most helpful comment

Hi all, sorry for the delayed response - this should be possible in MLflow >= 1.0 by using custom Python models (see the docs), in particular this example - you can define a wrapper model class that loads the persisted sklearn model & returns the results of predict_proba. Please feel free to reopen with any questions!

All 4 comments

Hi,

a quick fix would be to overwrite the "predict" function of your sklearn model with "predict_proba" before saving it. This is a bit hacky though. Not sure what the view of the core dev team is, but if they want to adress this more nicely, I'd be happy to pick it up.

Hi,

Thanks for your reply.
I used to rewrite predict () into predict_proba () by myself before too. I believe there is a demand for data scientists who wish to use predict_proba ().

I have a similar use case but with another custom function predict_distribution.
For now, I will override the predict method during the training but it would be better to offer a way to do it natively. Any help or suggestions are welcome. Thanks in advance. :)

Hi all, sorry for the delayed response - this should be possible in MLflow >= 1.0 by using custom Python models (see the docs), in particular this example - you can define a wrapper model class that loads the persisted sklearn model & returns the results of predict_proba. Please feel free to reopen with any questions!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nielsmitie picture Nielsmitie  路  4Comments

lqdev picture lqdev  路  4Comments

chrissng picture chrissng  路  3Comments

spapini picture spapini  路  4Comments

nkarpovdb picture nkarpovdb  路  5Comments