To create a pre-trained model for C#

I created a model with machine learning. Using the library Accord.NET. I would like to keep the pre-trained model in a file (not in the RAM memory) how this is possible?

Note: not necessary to create the model with Accord.NET could be with Python (TensorFlow, PyTorch, etc) but to use the pre-trained model from my desktop application in C#.

Topic .net machine-learning

Category Data Science


One way is to :

  1. Build and train the model in Python (TensorFlow)
  2. Use ml.net Library to execute the model in .net CLR. See the Docs.

Welcome to the site - great first question!

In your scenario (assuming I understand it correctly) you have a saved model in python right? So, what I would do is create a new API layer (written in python, using something like the Flask framework) and I would create API endpoints for your algorithmic functions (could be as simple as just 1 for your predict function).

From there, you could run that python script on a server and expose that API to the outside world and it will run/respond just like any other REST API service. At that point, it would be fairly trivial to write C# code to access the API (or any other language you want).

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.