submit.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. function submit()
  2. addpath('./lib');
  3. conf.assignmentSlug = 'logistic-regression';
  4. conf.itemName = 'Logistic Regression';
  5. conf.partArrays = { ...
  6. { ...
  7. '1', ...
  8. { 'sigmoid.m' }, ...
  9. 'Sigmoid Function', ...
  10. }, ...
  11. { ...
  12. '2', ...
  13. { 'costFunction.m' }, ...
  14. 'Logistic Regression Cost', ...
  15. }, ...
  16. { ...
  17. '3', ...
  18. { 'costFunction.m' }, ...
  19. 'Logistic Regression Gradient', ...
  20. }, ...
  21. { ...
  22. '4', ...
  23. { 'predict.m' }, ...
  24. 'Predict', ...
  25. }, ...
  26. { ...
  27. '5', ...
  28. { 'costFunctionReg.m' }, ...
  29. 'Regularized Logistic Regression Cost', ...
  30. }, ...
  31. { ...
  32. '6', ...
  33. { 'costFunctionReg.m' }, ...
  34. 'Regularized Logistic Regression Gradient', ...
  35. }, ...
  36. };
  37. conf.output = @output;
  38. submitWithConfiguration(conf);
  39. end
  40. function out = output(partId, auxstring)
  41. % Random Test Cases
  42. X = [ones(20,1) (exp(1) * sin(1:1:20))' (exp(0.5) * cos(1:1:20))'];
  43. y = sin(X(:,1) + X(:,2)) > 0;
  44. if partId == '1'
  45. out = sprintf('%0.5f ', sigmoid(X));
  46. elseif partId == '2'
  47. out = sprintf('%0.5f ', costFunction([0.25 0.5 -0.5]', X, y));
  48. elseif partId == '3'
  49. [cost, grad] = costFunction([0.25 0.5 -0.5]', X, y);
  50. out = sprintf('%0.5f ', grad);
  51. elseif partId == '4'
  52. out = sprintf('%0.5f ', predict([0.25 0.5 -0.5]', X));
  53. elseif partId == '5'
  54. out = sprintf('%0.5f ', costFunctionReg([0.25 0.5 -0.5]', X, y, 0.1));
  55. elseif partId == '6'
  56. [cost, grad] = costFunctionReg([0.25 0.5 -0.5]', X, y, 0.1);
  57. out = sprintf('%0.5f ', grad);
  58. end
  59. end