Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import WEKA model to MATLAB

Does anyone know how to reuse a WEKA model in MATLAB? I've recently created a Bayes Net model in WEKA, and I want to import that model in MATLAB so I can re-create the Bayesian Network in MATLAB.

Someone help please!!

like image 444
cjxh Avatar asked Jul 08 '12 05:07

cjxh


1 Answers

You can use Weka in MATLAB by importing weka.jar. Here is a small .m file script showing how to use Weka's BayesNet in MATLAB, written by Muhammad Shoaib Sehgal.

% Note: You can either set WEKA_HOME as an environment variable or pass
% absolute path of weka.jar to javaaddpath. For example,
% javaaddpath('c:\weka\bin\weka.jar');

javaaddpath('WEKA_HOME/weka.jar');

clear all
clc

import weka.classifiers.Classifier
import weka.classifiers.bayes.BayesNet
import weka.classifiers.Evaluation;

% calling classifier from matlab
v1 = java.lang.String('-t');
%v2 = java.lang.String('D:\Shoaib\BioMANTA\bioManta code\classification\loc_nlboost\bn\loc_trDt.csv');
v2 = java.lang.String('WEKA_HOME\trainData.arff');

v3 = java.lang.String('-T');
v4 = java.lang.String('WEKA_HOME\testDATA.arff');

prm = cat(1,v1,v2,v3,v4);

Evaluation.evaluateModel(javaObject('weka.classifiers.bayes.BayesNet'),prm);
like image 79
Sicco Avatar answered Sep 25 '22 19:09

Sicco