Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please do B~F <logistic Starter.m> clear all; close all; clc load BreastCancerSm

ID: 3839540 • Letter: P

Question

Please do B~F

<logistic Starter.m>

clear all; close all; clc

load BreastCancerSmall.mat

b = BreastCancerSmall(:, end); % 0 means benign; 1 means malignant
A = BreastCancerSmall(:, 1:9); % first columns are the predictors

% normalize columns of A
for i = 1:9
A(:,i) = A(:,i)/norm(A(:,i));
end

lambda = .1;
tolerance = 1e-5;

[m,n] = size(A);

%L = norm(A(:))^2;
L = norm(A)^2;
converged = 0;

x = zeros(n,1);
iter = 0;
while(~converged)
iter = iter +1;   
[f,g] = myLogistic(x, A, b, lambda);
x = x - g/L;   
converged = norm(g) < tolerance;
fprintf('iter: %d, value: %7.3f, norm g: %7.3e ', iter, f, norm(g));

end

<mylogistic.m>

function [ f, g ] = myLogistic( x, A, b, lambda)
%myLogistic: computes value and gradient for ridge logistic regresison
% sum log(1 + exp(a_i'x) - b_i a_i'x + lambda ||x||^2


[m,n] = size(A);


f = 0.0;
g = zeros(n,1); % column vector of zeros

% compute f
for i = 1:m
ai = A(i,:);
aix = ai*x;
f = f + log(1+exp(aix)) - b(i)*aix;
% add code inside the loop to compue gradient.
end

% Add modification for the ridge regularization.
f = f + 0.5*lambda * norm(x)^2;
g = g + lambda*x;

end

(2) The ridge-regularized logistic regression problem is given by ex min i-1 (a) Compute the gradient Vf(z), and write down your work and final formula here Hint: the derivative of the sum is the sum of the derivatives. Remember the chain rule, and remember you know how to differentiate r. (b) Implement your solution in the starter code function myLogistic.m. Once you do this, the file logisticStarter should run correctly. (c) What are the coefficients? Give the final z here Which columns have positive signs and which have negative signs How might you interpret these answers (d) Modify the algorithm to solve the problem min Give the code of the final algorithm there. (e) Play with the A parameter until you have only one nonzero coefficient in the final solution a. What value of A did you use? What's the name of the non-zero column that you found? (check the original BreastCancer.csv dataset).

Explanation / Answer

Firstly, we have given a data file that has the EEG signal of a patient.our task is to find the seizure part from the given signal. After detecting the seizure, we have to plot a pulse signal on the given signal, pulse of 1 on the seizure part, and 0 everywhere else.

As per my perspective, The method you were following is not correct, why because your aim is to detect the seizure part of EEG signal.

For that you made a model signal out of seizure part and normal part. Then correlating the EEG signal with model signal. If you do like this, If EEG signal don't has the seizure part, your MeanS, freS parameters will appear in the output correlated signal.

Method of Idea:

1. Take the fft of seizure part of EEG signal and normal part of EEG signal, Identify the differences in frequency and amplitude.

2. Now, take the EEG signal from a patient, apply fft to it. Find the frequency and amplitude components relate to the seizure part .

3. Then generate a pulse signal at seizure frequencies as logic 1 and normal frequencies as logic 0.

You didn't post the EEG signal, otherwise i can give the matlab code for you. If any further information post me again.