Skip to main content

Posts

Showing posts from October, 2013

Call matlab from C/C++ java or Call C/C++ java from Matlab matlab binary calling

Call Matlab from c/c++ , java etc http://www.mathworks.com/help/matlab/matlab_external/calling-matlab-software-from-a-c-application.html http://www.mathworks.com/help/matlab/matlab_external/compiling-engine-applications-with-the-mex-command.html#bsq78dr-9 Set env var First export LD_LIBRARY_PATH=/mnt/kaustapps/MATLAB-faculty/R2011b.app/bin/glnxa64/:/mnt/kaustapps/MATLAB-faculty/R2011b.app/sys/os/glnxa64/:$LD_LIBRARY_PATH UNIX Engine Example engdemo To verify the build process on your computer, use the C example engdemo.c or the C++ example engdemo.cpp . Copy one of the programs, for example, engdemo.c , to your current working folder: copyfile(fullfile(matlabroot,... 'extern','examples','eng_mat','engdemo.c'),... '.', 'f'); Build the executable file: mex('-v', '-f', fullfile(matlabroot,... 'bin','engopts.sh'),... 'engdemo.c'); Verify that the build worked by looking i

libsvm usage

FAQ ===== http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html#/Q4:_Training_and_prediction DONWLOAD ======== Just need to download 1 zip file from main page. That's all. http://www.csie.ntu.edu.tw/~cjlin/libsvm/ INSTALL ========== make If you want to use parameter estimation, you need to change the code a bit and do following make clean; make install; DATAFORMAT ============== label  1:feat#1  2:feat#2  3:feat#3      N:feat#N Some available data =============== http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/ Use heart_scale data. It works perfectly for all plot, cv and parameter estimation. 2-class CLASSIFICATION with RBF kernel with 5 fold CV ================================= train (support vectors are generated): ./svm-train -s 0 -t 2   -g  0.03125 -c 0.25   train.dat  train.model train with CV(No support  vectors are shown, just show your score: AUC,F-score) ./svm-train -s 0 -t 2 -v 5  train.dat  > train.cv testing: ./svm-pr

matlab cross validation with svm [draft not final]

function test clc; matPos = csvread('pos.dat'); noPos= size(matPos,1); noFeature = size(matPos,2); labelPos= ones(noPos,1); % matPos= [matPos labelPos ]; matNeg = csvread('neg.dat'); noNeg= size(matNeg,1); labelNeg= -1*ones(noNeg,1); % matNeg= [matNeg labelNeg ]; % svmStruct = svmtrain(featureInTrain,featureOutTrain,'kernel_function','linear'  , 'options' ,smo_opts); %,'rbf_sigma',100,'boxconstraint',25 noFold=5; c = cvpartition([labelPos ; labelNeg],'kfold', noFold); strArray = java_array('java.lang.String', 2); strArray(1) = java.lang.String('1'); strArray(2) = java.lang.String('-1'); myorder = cell(strArray) f = @(xtr,ytr,xte,yte) confusionmat(yte,@(xtr,ytr,xte)crossfun(xtr,ytr,xte, exp(z(1)),exp(z(2))),'order', [1 -1] ); cfMat = crossval(f,[matPos; matNeg], [ labelPos ; labelNeg],'partition',c); cfMat = reshape(sum(cfMat),3,3) minfn = @(z)crossval('mcr',[matPos; matNeg