What is MLEM?MLEM is an open-source tool that allows users to simplify machine learning model deployment. With MLEM, users can run their machine learning models anywhere by wrapping models as a Python package or Docker Image, or deploying them to Heroku (SageMaker, Kubernetes, and more platforms coming soon). MLEM is written in Python, and runs as a microservice with applications calling for a simple HTTP API. Our HTTP client was written in C# and Java, and was basically designed to help software developers use a machine learning approach to create intelligent applications, based on Java or .NET, without needing a deep knowledge of MLEM.
What are .NET Client and Java Client for MLEM?.NET and Java clients are libraries that allow users to connect with MLEM API simply and easily, as well as integrate the MLEM model functionality to their .NET or Java project. It also supports request body validation by schema received from the MLEM server, and also offers a standard logging interface to use. To implement a client, Akvelon used a standard HTTP Client with a given host, logger, and base models for some cases. The client provides several methods for using MLEM technologies with given rules. This is the main part of creating our custom MLEM client for Java or .NET, because having a stable application with minimum functionality is a good way to support it now and makes for easier improvements in the future.
Getting Started with Java ClientTo get started with MLEM Java Client, you first have to explore a project’s repository: https://github.com/akvelon/MLEM-SDK-for-Java. You also should install an IDE, create a project, and add
MlemJClient.jar to your application classpath. If you are familiar with the Java language, looking into the JavaDoc should be the easiest way for you to start. The
MlemJClient.java interface is the one you may want to look at first.
And that’s it, you are ready to go!
After the installation is complete, you can send some requests using MLEM Java Client:
1. Create the MlemJClient object
2. Create the request body
3. Send the /predict request
4. Send the /call request with Illegal path name
The response will be:
error text: The path predict_proba123 is not found in schema; Available path list: [sklearn_predict, predict_proba, predict, sklearn_predict_proba].
Getting Started with MLEM .NET ClientMLEM .Net client is a NET class library based on NET 6. Prerequisites:
- Cloned repo – https://github.com/akvelon/MLEM-SDK-for-C-Sharp
- Visual Studio Code or vsbuild console tool – to enable building the MLEM-SDK project
- Switch to ‘main’ branch (git checkout main)
- Build the project in Visual Studio (see build docs for more details) using release configuration. As result – there will be the following
dll/deps.jsonfiles in target binaries folder (usually it is <project path>\bin\Release\net<net version> ):
MlemApi.dll– main client
ModelRepository.dll– assembly containing some example models you can use to play with MLEM .Net client
MlemApi.deps.json– client dependencies file
- Create the
MlemApiClientobject in a simple variant
var mlemClient = new MlemApiClient("https://example-mlem-get-started-app.herokuapp.com/");2. Define the class for the request object 3. Define the input data 4. Do PredictAsync 5. Do CallAsync For more examples – feel free to explore our MLEM client repo.
ConclusionMLEM makes the process of integrating, packaging, and deploying machine learning models much easier. With Akvelon’s .NET and Java clients, it is now possible to apply MLEM models much easier for non-Python projects that were developed in .NET and Java. It is now possible to use these clients with your existing or new applications:
- Web (ASP.Net, Java Spring)
- Mobile (Xamarin, Android)
- Desktop (WPF, WinForms, Java Spring, Java Swing)
Alexander Dudko, Software Development Engineer at Akvelon
Roman Shchukin, Software Development Engineer at Akvelon
Anatoly Bolshakov, Software Development Engineer at Akvelon
Denis Nosov, Project Manager at Akvelon
Vladimir Krestov, Software Development Engineer at Akvelon
Ayagoz Mussabayeva, Data Scientist at Akvelon