How can I call scikit-learn classifiers from Java?

前端 未结 6 1422
悲&欢浪女
悲&欢浪女 2020-12-07 17:00

I have a classifier that I trained using Python\'s scikit-learn. How can I use the classifier from a Java program? Can I use Jython? Is there some way to save the classifier

6条回答
  •  無奈伤痛
    2020-12-07 18:03

    There is JPMML project for this purpose.

    First, you can serialize scikit-learn model to PMML (which is XML internally) using sklearn2pmml library directly from python or dump it in python first and convert using jpmml-sklearn in java or from a command line provided by this library. Next, you can load pmml file, deserialize and execute loaded model using jpmml-evaluator in your Java code.

    This way works with not all scikit-learn models, but with many of them.

提交回复
热议问题