Search code examples
matlabwekamodels

Deploying Matlab gui exe with Weka Models


My problem is that when i deploy my Program along with weka models. The resulting error is that it cant read the weka model file.

Here is the structure of the Files

ModelLoadmodel.m

Contains The ff code

javaaddpath('weka.jar');
addpath('SurfModels');
loadedModel = wekaLoadModel('RandomForestK40Surf.model');

The Folder wherein all of these file contains has a structure of

  • WekaLoadmodel.m

  • SurfRandomForestK40.model

  • Folder"WekaLab" which has a

    • WekaLoadModel.m
    • Weka.jar

When i try to use the commandline function of

loadedModel = wekaLoadModel('RandomForestK40Surf.model');

The loadedModel is successfully loaded but when i deploy it using deploytool and the output is Error reading model file

The WekaLoadmodel.m Contains

if ~exist(filename, 'file')
    error('WEKALAB:wekaLoadModel:FileNotFound', 'No file found at %s', filename);
end
%% Code
try
    modelObj = weka.core.SerializationHelper.read(filename);
catch err
    error('WEKALAB:wekaLoadModel:ReadError', 'Error reading model file at %s', filename);
end
end

It came from https://www.mathworks.com/matlabcentral/fileexchange/58675-wekalab--bridging-weka-and-matlab . Is there some sort of problem when loading other file extension in matlab deploytool?


Solution

  • The answer is don't put it in a folder. Just take all the .m files and compile it. Simple as that