Modelling of Ic Classifier Using Logistic Regression: %initialization
Modelling of Ic Classifier Using Logistic Regression: %initialization
Introduction
(a). Under mentioned code has been written in MATLAB for bifurcation of ICs :-
----------------------------------------------------------------------------------------------------------------
%Initialization
%Loading Training Data and allocating ones for acceptable ICs and zeros for
unacceptable ICs
filename='datatr.xlsx'
Range1= 'A2:A27';
Range2= 'B2:B27';
X1 = xlsread(filename,Range1);
X2 = xlsread (filename,Range2);
X = repelem (X1,X2);
Y=[ones(500,1); zeros(500,1)];
figure('name','Logistic Regression Training Data Plot')
scatter(X,Y,60,'m', 'filled');
xlabel('Power (watts)')
ylabel('Bifurcation of ICs')
hold on;
%Plotting Sigmoid
fplot(@(X) (1 ./ (1 + exp(-(theta1+theta2*X)))), [0.3 0.4], 'b');
legend('Training Set', 'Decision Boundary', 'Sigmoid')
Predicted=round(Predict');
Accuracy= ((TP+TN)./200)*100;
Precision= (TP./(TP+FP));
Recall= (TP./(TP+FN));
Fscore= 2*((Precision*Recall)./(Precision+Recall));
1. Compute (theta, X, Y)
2. Sigmoid Function
--------------------------------------------------------------------------------------------------------------
theta1+theta2x>=0
theta2x=-theta1
X = -theta1/theta2
MATLAB code for calculation and plotting of decision boundary is appended below
MATLAB Code for Decision Boundary
Cost function and important parameters (thetas) have been calculated using
following MATLAB
Cost Function comes out to be 0.6931. The values for cost function and thetas have
been optimized by using undermentioned code
Cost= 0.0314
theta1 = 630.5520
theta2 = -1.8506e+03
Plot of Sigmoid Function
Sigmoid Function has been plotted using values of calculated theta1 and theta2 and
same is appended below:-
Confusion Matrix
(d) After calculation of hypothesis, cost and thetas, Test data was predicted using
the developed classifier. The predicted values and actual power values of test data
were then compared to plot confusion matrix
C= 97 3
2 98