Exporting machine learning model to .NET Assembly

조회 수: 1 (최근 30일)
Steven Feingold
Steven Feingold 2019년 5월 2일
답변: undefined undefined 2024년 3월 7일
I have created a .NET assembly using the Matlab Library Compiler and included it in a Visual Studio 2015 C# project. Everything works fine except for when I attempt to make a prediction using the model. The Matlab code looks like this:
load('C:\...\dispositionModel.mat', 'trainedModel1');
result = trainedModel1.predictFcn(data);
I get the following error:
Warning: Could not find appropriate function on path loading function handle C:\Program Files\MATLAB\R2018b\toolbox\stats\mlearnapp\+mlearnapp\+internal\+model\DatasetSpecification.m>@(x)exportableModel.predictFcn(predictorExtractionFcn(x))
I'm not sure why it's calling functions on the R2018b path, instead of the MATLAB Runtime path. I have included a pragma in my function
%#function fitctree
Looking through other help documentation, I'm only seeing references to C/C++ for using machine learning models with generated code. Is it even possible with C#?

채택된 답변

Steven Feingold
Steven Feingold 2019년 7월 2일
The answer was to call the prediction function differently.
ModelClassificationEnsemble = trainedModel1.ClassificationEnsemble;
result = predict(ModelClassificationEnsemble, data);

추가 답변 (1개)

undefined undefined
undefined undefined 2024년 3월 7일
Hi
I have trained a neural network in Matlab, and now would like to predict using this trained network from C# code.
How do I save the network in a format readable by C# ?
How do I then call the predict function form C#?
What needs to installed on my C# machine? (currently it doesn not have Matlab runtime, sice I developed the net on another computer)
Thanks in advance,
Gal

카테고리

Help CenterFile Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by