Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save limzunyuan/af11cd37e76b0918be73 to your computer and use it in GitHub Desktop.
Save limzunyuan/af11cd37e76b0918be73 to your computer and use it in GitHub Desktop.
function[results] = ten_fold_cross_validation_parameter_estimation(x, y)
results = [];
% Train and pick the best tree using 10-fold cross validation.
%[x2, y2] = ANNdata(x, y);
for hidden_neurons_1 = 10:25
hidden_neurons_1
for hidden_neurons_2 = 10:25
hidden_neurons_2
for lr = 0.5:0.05:0.6
lr
cum_sum_confusion_matrix = zeros(2);
for i = 1 : 10
[train_idx, validation_idx] = partition(i, x);
net = create_traingd(x, y, [hidden_neurons_1, hidden_neurons_2], 100, ...
train_idx, validation_idx, [], lr);
predicted = testANN(net, x(:, validation_idx), @NNout2labels);
cum_sum_confusion_matrix = cum_sum_confusion_matrix ...
+ confusion_matrix(2, predicted, y(validation_idx)');
end
avg_confusion_matrix = cum_sum_confusion_matrix / 10
results = [results; mean(f1_measure(avg_confusion_matrix))]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment