Using MATLAB c. plot the data and the best-fit logistic regression model Challen
ID: 3817737 • Letter: U
Question
Using MATLAB
c. plot the data and the best-fit logistic regression model
Challenger ORing:
Use the Temperature and failure data from the Challenger O-rings in lecture_18 (challenger_oring.csv). Your independent variable is temerature and your dependent variable is failure (1 = fail, 0 = pass). Create a function called cost_logistic.m that takes the vector a, and independent variable x and dependent variable y. Use the function, sigma(t) = 1/1+e^-t where t = a_0 + a_1x. Use the cost function. J(a_0, a_1) 1/m sigma^n_i=1 [-y_i log (sigma(t_i)) - (1 - y_i) log((1 - sigma(t_i)))] and gradient partial J/partial a_i = 1/m sigma^N_k=1 (sigma(t_k) - y_k) x^i_k where $x_{k}^{i} is the k-th value of temperature raised to the i-th power (0, and 1) a. edit cost_logistic.m so that the output is [J, grad] or [cost, gradient] b. use the following code to solve for a0 and al % Set options for fminunc options = optimset ('GradObj', 'On', 'MaxIter' 400); % Run fminunc to obtain the optima theta % This function will return theta and the cost [theta cost] =... fminunc(@ (a) (costFunction(a, x, y)), initial_a options);Explanation / Answer
plot(X,Y)
plot(X,Y,LineSpec)
plot(X1,Y1,...,Xn,Yn)
plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn)
plot(Y)
plot(Y,LineSpec)
plot(___,Name,Value)
plot(ax,___)
h = plot(___)
Portrayal
case
plot(X,Y) makes a 2-D line plot of the information in Y versus the comparing values in X.
On the off chance that X and Y are both vectors, then they should have level with length. The plot work plots Y versus X.
In the event that X and Y are both grids, then they should have level with size. The plot work plots sections of Y versus segments of X.
On the off chance that one of X or Y is a vector and the other is a framework, then the grid must have measurements with the end goal that one of its measurements rises to the vector length. On the off chance that the quantity of framework lines levels with the vector length, then the plot work plots every grid segment versus the vector. On the off chance that the quantity of framework sections meets the vector length, then the capacity plots every network push versus the vector. On the off chance that the network is square, then the capacity plots every segment versus the vector.
In the event that one of X or Y is a scalar and the other is either a scalar or a vector, then the plot work plots discrete focuses. Be that as it may, to see the focuses you should determine a marker image, for instance, plot(X,Y,'o').
plot(X,Y,LineSpec) sets the line style, marker image, and shading.
case
plot(X1,Y1,...,Xn,Yn) plots various X, Y sets utilizing similar tomahawks for all lines.
illustration
plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn) sets the line style, marker sort, and shading for each line. You can blend X, Y, LineSpec triplets with X, Y sets. For instance, plot(X1,Y1,X2,Y2,LineSpec2,X3,Y3).
illustration
plot(Y) makes a 2-D line plot of the information in Y versus the record of each esteem.
On the off chance that Y is a vector, then the x-pivot scale ranges from 1 to length(Y).
On the off chance that Y is a framework, then the plot work plots the segments of Y versus their line number. The x-pivot scale ranges from 1 to the quantity of lines in Y.
In the event that Y is mind boggling, then the plot work plots the nonexistent piece of Y versus the genuine piece of Y, with the end goal that plot(Y) is proportional to plot(real(Y),imag(Y)).
plot(Y,LineSpec) sets the line style, marker image, and shading.
illustration
plot(___,Name,Value) indicates line properties utilizing at least one Name,Value combine contentions. For a rundown of properties, see Chart Line Properties. Utilize this choice with any of the information contention blends in the past grammar. Name,Value match settings apply to every one of the lines plotted.
case
plot(ax,___) makes the line in the tomahawks determined by hatchet rather than in the present tomahawks (gca). The alternative hatchet can go before any of the information contention mixes in the past language structures.
illustration
h = plot(___) gives back a segment vector of outline line objects. Utilize h to alter properties of a particular diagram line after it is made. For a rundown of properties, see Chart Line Properties.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.