Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 4/Programming Assignment - 3/machine-learning-ex3/ex3/submit.m
864 views
1
function submit()
2
addpath('./lib');
3
4
conf.assignmentSlug = 'multi-class-classification-and-neural-networks';
5
conf.itemName = 'Multi-class Classification and Neural Networks';
6
conf.partArrays = { ...
7
{ ...
8
'1', ...
9
{ 'lrCostFunction.m' }, ...
10
'Regularized Logistic Regression', ...
11
}, ...
12
{ ...
13
'2', ...
14
{ 'oneVsAll.m' }, ...
15
'One-vs-All Classifier Training', ...
16
}, ...
17
{ ...
18
'3', ...
19
{ 'predictOneVsAll.m' }, ...
20
'One-vs-All Classifier Prediction', ...
21
}, ...
22
{ ...
23
'4', ...
24
{ 'predict.m' }, ...
25
'Neural Network Prediction Function' ...
26
}, ...
27
};
28
conf.output = @output;
29
30
submitWithConfiguration(conf);
31
end
32
33
function out = output(partId, auxdata)
34
% Random Test Cases
35
X = [ones(20,1) (exp(1) * sin(1:1:20))' (exp(0.5) * cos(1:1:20))'];
36
y = sin(X(:,1) + X(:,2)) > 0;
37
Xm = [ -1 -1 ; -1 -2 ; -2 -1 ; -2 -2 ; ...
38
1 1 ; 1 2 ; 2 1 ; 2 2 ; ...
39
-1 1 ; -1 2 ; -2 1 ; -2 2 ; ...
40
1 -1 ; 1 -2 ; -2 -1 ; -2 -2 ];
41
ym = [ 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 ]';
42
t1 = sin(reshape(1:2:24, 4, 3));
43
t2 = cos(reshape(1:2:40, 4, 5));
44
45
if partId == '1'
46
[J, grad] = lrCostFunction([0.25 0.5 -0.5]', X, y, 0.1);
47
out = sprintf('%0.5f ', J);
48
out = [out sprintf('%0.5f ', grad)];
49
elseif partId == '2'
50
out = sprintf('%0.5f ', oneVsAll(Xm, ym, 4, 0.1));
51
elseif partId == '3'
52
out = sprintf('%0.5f ', predictOneVsAll(t1, Xm));
53
elseif partId == '4'
54
out = sprintf('%0.5f ', predict(t1, t2, Xm));
55
end
56
end
57
58