submit.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. function submit()
  2. addpath('./lib');
  3. conf.assignmentSlug = 'linear-regression';
  4. conf.itemName = 'Linear Regression with Multiple Variables';
  5. conf.partArrays = { ...
  6. { ...
  7. '1', ...
  8. { 'warmUpExercise.m' }, ...
  9. 'Warm-up Exercise', ...
  10. }, ...
  11. { ...
  12. '2', ...
  13. { 'computeCost.m' }, ...
  14. 'Computing Cost (for One Variable)', ...
  15. }, ...
  16. { ...
  17. '3', ...
  18. { 'gradientDescent.m' }, ...
  19. 'Gradient Descent (for One Variable)', ...
  20. }, ...
  21. { ...
  22. '4', ...
  23. { 'featureNormalize.m' }, ...
  24. 'Feature Normalization', ...
  25. }, ...
  26. { ...
  27. '5', ...
  28. { 'computeCostMulti.m' }, ...
  29. 'Computing Cost (for Multiple Variables)', ...
  30. }, ...
  31. { ...
  32. '6', ...
  33. { 'gradientDescentMulti.m' }, ...
  34. 'Gradient Descent (for Multiple Variables)', ...
  35. }, ...
  36. { ...
  37. '7', ...
  38. { 'normalEqn.m' }, ...
  39. 'Normal Equations', ...
  40. }, ...
  41. };
  42. conf.output = @output;
  43. submitWithConfiguration(conf);
  44. end
  45. function out = output(partId)
  46. % Random Test Cases
  47. X1 = [ones(20,1) (exp(1) + exp(2) * (0.1:0.1:2))'];
  48. Y1 = X1(:,2) + sin(X1(:,1)) + cos(X1(:,2));
  49. X2 = [X1 X1(:,2).^0.5 X1(:,2).^0.25];
  50. Y2 = Y1.^0.5 + Y1;
  51. if partId == '1'
  52. out = sprintf('%0.5f ', warmUpExercise());
  53. elseif partId == '2'
  54. out = sprintf('%0.5f ', computeCost(X1, Y1, [0.5 -0.5]'));
  55. elseif partId == '3'
  56. out = sprintf('%0.5f ', gradientDescent(X1, Y1, [0.5 -0.5]', 0.01, 10));
  57. elseif partId == '4'
  58. out = sprintf('%0.5f ', featureNormalize(X2(:,2:4)));
  59. elseif partId == '5'
  60. out = sprintf('%0.5f ', computeCostMulti(X2, Y2, [0.1 0.2 0.3 0.4]'));
  61. elseif partId == '6'
  62. out = sprintf('%0.5f ', gradientDescentMulti(X2, Y2, [-0.1 -0.2 -0.3 -0.4]', 0.01, 10));
  63. elseif partId == '7'
  64. out = sprintf('%0.5f ', normalEqn(X2, Y2));
  65. end
  66. end