Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a scikit learn model from C#

I made many models with scikit learn, and i want to make predictions with these models from a C# program, is there any API which will help me to do that ?.

like image 908
Nadjib Bendaoud Avatar asked Dec 21 '17 19:12

Nadjib Bendaoud


People also ask

What is fit () in sklearn?

The fit() method takes the training data as arguments, which can be one array in the case of unsupervised learning, or two arrays in the case of supervised learning. Note that the model is fitted using X and y , but the object holds no reference to X and y .


Video Answer


1 Answers

It is not possible to load sklearn models in C# directly (for my knowledge).

There is a language for the language-/tool-independent exchange of ML models called PMML. sklearn doesn't bring native support for PMML however. If you're lucky, your model/pipeline might be exportable to PMML using third party tools and loadable in C# using third party libraries.

The more reliable and way more flexible way is to do the prediction in Python using sklearn and communicate with your C# program via files or (better) a web service. Olivier Grisel (one of the sklearn authors) concisely describes your options in this post.

like image 117
Michael Tannenbaum Avatar answered Oct 11 '22 05:10

Michael Tannenbaum