[b4b313]: / classification / SMOTEBoost / ClassifierPredict.m

Download this file

20 lines (17 with data), 621 Bytes

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