Switch to unified view

a b/classification/SMOTEBoost/ClassifierPredict.m
1
function prediction = ClassifierPredict(data,model)
2
% Predicting the labels of the test instances
3
% Input: data = test data
4
%        model = the trained model
5
%        type = type of classifier
6
% Output: prediction = prediction labels
7
8
javaaddpath('weka.jar');
9
10
CSVtoARFF(data,'test','test');
11
test_file = 'test.arff';
12
reader = javaObject('java.io.FileReader', test_file);
13
test = javaObject('weka.core.Instances', reader);
14
test.setClassIndex(test.numAttributes() - 1);
15
16
prediction = [];
17
for i = 0 : size(data,1) - 1
18
    p = model.classifyInstance(test.instance(i));
19
    prediction = [prediction; p];
20
end