1-Change this code from Matlab to Phython: initial_theta = zeros (size (X, 2), 1); 46 47 48 lambda = 1; options = optimoptions (@ fminunc, 'Algorithm', 'Quasi-Newton','Gradobj', 'on', [theta, J,...


1-Change this code from Matlab to Phython:<br>initial_theta = zeros (size (X, 2), 1);<br>46<br>47<br>48<br>lambda = 1;<br>options = optimoptions (@ fminunc, 'Algorithm', 'Quasi-Newton','Gradobj', 'on',<br>[theta, J, exit_flag] = fminunc (@ (t) (costFunctionReg (t, X, y, lambda)), initial_theta, options);<br>plotDecisionBoundary (theta, X, y);<br>49<br>'MaxIter', 1000);<br>50<br>51<br>52<br>hold on;<br>title (sprintf ('lambda = %g', lambda))<br>xlabel ('Microchip Test 1')<br>ylabel ('Microchip Test 2')<br>legend ('y = 1', 'y = 0',<br>53<br>54<br>55<br>56<br>'Decision boundary')<br>57<br>hold off;<br>p = predict (theta, X);<br>fprintf('Train Accuracy: %f\n', mean (double (p == y)) * 100);<br>58<br>59<br>

Extracted text: 1-Change this code from Matlab to Phython: initial_theta = zeros (size (X, 2), 1); 46 47 48 lambda = 1; options = optimoptions (@ fminunc, 'Algorithm', 'Quasi-Newton','Gradobj', 'on', [theta, J, exit_flag] = fminunc (@ (t) (costFunctionReg (t, X, y, lambda)), initial_theta, options); plotDecisionBoundary (theta, X, y); 49 'MaxIter', 1000); 50 51 52 hold on; title (sprintf ('lambda = %g', lambda)) xlabel ('Microchip Test 1') ylabel ('Microchip Test 2') legend ('y = 1', 'y = 0', 53 54 55 56 'Decision boundary') 57 hold off; p = predict (theta, X); fprintf('Train Accuracy: %f\n', mean (double (p == y)) * 100); 58 59

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here