-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ4, Q5 main_code.m
48 lines (32 loc) · 1.48 KB
/
Q4, Q5 main_code.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
%% 5. Experiment with Caltech dataset for image categorisation (Coursework 1)
param.num = 10;
param.depth = 10; % trees depth
param.splitNum = 3; % Number of trials in split function
param.split = 'IG'; % Currently support 'information gain' only
% Complete getData.m by writing your own lines of code to obtain the visual
% vocabulary and the bag-of-words histograms for both training and testing data.
% You can use any existing code for K-means (note different codes require different memory and computation time).
%[data_train, data_test] = getData('Caltech')a;
%filename = 'datatraintest.xlsx';
%writematrix(data_train, filename,'Sheet', 1);
%writematrix(data_test, filename, 'Sheet', 2);
init ;
%data_train = readmatrix("datatraintest.xlsx", 'Sheet','Sheet1');
%data_test = readmatridatatraintest.xlsx", 'Sheet','Sheet2');
%[data_train, data_test] = getData('Caltech', 512);
for N = [10] % Number of trees, try {1,3,5,10, or 20}
param.num = 19;
param.depth = 5; % trees depth
param.splitNum = 10; % Number of trials in split function
param.split = 'IG'; % Currently support 'information gain' only
% Select dataset
[data_train, data_test] = getData('Caltech', N); % {'Toy_Gaussian', 'Toy_Spiral', 'Toy_Circle', 'Caltech'}
% Train Random Forest
trees = growTrees(data_train, param);
% Test Random Forest
testTrees_script;
% Visualise
%visualise(data_train,p_rf,[],0);
%disp('Press any key to continue');
%pause;
end