Saturday 26 November 2016

About The Great Worrier "Shivaji Maharaj"

Shivaji Bhonsle (19 Feb 1630 – 3 April 1680), also known as Chhatrapati Shivaji Maharaj, was an Indian warrior king and a member of the Bhonsle Maratha clan. Shivaji carved out an enclave from the declining Adilshahi sultanate of Bijapur that formed the genesis of the Maratha Empire. In 1674, he was formally crowned as the Chhatrapati (Monarch) of his realm at Raigad.

Shivaji Maharaj established a competent and progressive civil rule with the help of a disciplined military and well-structured administrative organisations. He innovated military tactics, pioneering the guerrilla warfare methods (Shiva sutra or ganimi kava), which leveraged strategic factors like geography, speed, and surprise and focused pinpoint attacks to defeat his larger and more powerful enemies. He revived ancient Hindu political traditions and court conventions and promoted the usage of Marathi and Sanskrit, rather than Persian, in court and administration.
Shivaji Maharaj's legacy was to vary by observer and time but began to take on increased importance with the emergence of the Indian independence movement, as many elevated him as a proto-nationalist and hero of the Hindus. Particularly in Maharashtra, debates over his history and role have engendered great passion and sometimes even violence as disparate groups have sought to characterise him and his legacy.

Shivaji Maharaj was born in the hill-fort of Shivneri, near the city of Junnar in Pune district on 19 Feb. 1630. The Government of Maharashtra accepts 19 February 1630 as his birthdate; other suggested dates include 6 April 1627 or other dates near this day. Per legend, his mother named him Shivaji in honour of the goddess Shivai, to whom she had prayed for a healthy child. Shivaji was named after this local deity. Shivaji's father Shahaji Bhonsle was a Maratha general who served the Deccan Sultanates. His mother was Jijabai, the daughter of Lakhujirao Jadhav of Sindkhed (Sindkhed Raja). At the time of Shivaji's birth, the power in Deccan was shared by three Islamic sultanates: Bijapur, Ahmednagar, and Golconda. Shahaji often changed his loyalty between the Nizamshahi of Ahmadnagar, the Adilshah of Bijapur and the Mughals, but always kept his jagir (fiefdom) at Pune and his small army with him.

How to write Research Paper

  1. STEP 1. CHOOSE A TOPIC
  2. STEP 2. FIND INFORMATION
  3. STEP 3. STATE YOUR THESIS
  4. STEP 4. MAKE A TENTATIVE OUTLINE
  5. STEP 5. ORGANISE YOUR NOTES
  6. STEP 6. WRITE YOUR FIRST DRAFT
  7. STEP 7. REVISE YOUR OUTLINE AND DRAFT

    1. Checklist One

    1. 1. Is my thesis statement concise and clear?
    2. 2. Did I follow my outline? Did I miss anything?
    3. 3. Are my arguments presented in a logical sequence?
    4. 4. Are all sources properly cited to ensure that I am not plagiarizing?
    5. 5. Have I proved my thesis with strong supporting arguments?
    6. 6. Have I made my intentions and points clear in the essay?
    1. Checklist Two
    1. 1. Did I begin each paragraph with a proper topic sentence?
    1. 2. Have I supported my arguments with documented proof or examples?
    1. 3. Any run-on or unfinished sentences?
    1. 4. Any unnecessary or repetitious words?
    1. 5. Varying lengths of sentences?
    1. 6. Does one paragraph or idea flow smoothly into the next?
    1. 7. Any spelling or grammatical errors?
    1. 8. Quotes accurate in source, spelling, and punctuation? 
    1. 9. Are all my citations accurate and in correct format?
    1. 10. Did I avoid using contractions? Use "cannot" instead of "can't", "do not" instead of "don't"?
    1. 11. Did I use third person as much as possible? Avoid using phrases such as "I think", "I guess", "I suppose"
    1. 12. Have I made my points clear and interesting but remained objective?
    1. 13. Did I leave a sense of completion for my reader(s) at the end of the paper?

    1. 1. Is my thesis statement concise and clear?
      Re-read your paper for grammatical errors. Use a dictionary or a thesaurus as needed. Do a spell check. Correct all errors that you can spot and improve the overall quality of the paper to the best of your ability. Get someone else to read it over. Sometimes a second pair of eyes can see mistakes that you missed.
  8. STEP 8. TYPE FINAL PAPER


Friday 9 September 2016

Guassian membership Function in NN

%inputs
% XOR input for x1 and x2
input = [0 0; 0 1; 1 0; 1 1];
% Desired output of XOR
output = [0;1;1;0];
% Initialize the bias
bias = [-1 -1 -1];
% Learning coefficient
coeff = 0.7;
% Number of learning iterations
iterations = 10000;
% Calculate weights randomly using seed.
rand('state',sum(100*clock));
weights = -1 +2.*rand(3,3);

%with back propogation
for i = 1:iterations
   out = zeros(4,1);
   numIn = length (input(:,1));
   for j = 1:numIn
      % Hidden layer
      H1 = bias(1,1)*weights(1,1)     
          + input(j,1)*weights(1,2)
          + input(j,2)*weights(1,3);

      % Send data through sigmoid function 1/1+e^-x
      % Note that sigma is a different m file
      % that I created to run this operation
      x2(1) = sigma(H1);
      H2 = bias(1,2)*weights(2,1)
           + input(j,1)*weights(2,2)
           + input(j,2)*weights(2,3);
      x2(2) = sigma(H2);

      % Output layer
      x3_1 = bias(1,3)*weights(3,1)
             + x2(1)*weights(3,2)
             + x2(2)*weights(3,3);
      out(j) = sigma(x3_1);
     
      % Adjust delta values of weights
      % For output layer:
      % delta(wi) = xi*delta,
      % delta = (1-actual output)*(desired output - actual output)
      delta3_1 = out(j)*(1-out(j))*(output(j)-out(j));
     
      % Propagate the delta backwards into hidden layers
      delta2_1 = x2(1)*(1-x2(1))*weights(3,2)*delta3_1;
      delta2_2 = x2(2)*(1-x2(2))*weights(3,3)*delta3_1;
     
      % Add weight changes to original weights
      % And use the new weights to repeat process.
      % delta weight = coeff*x*delta
      for k = 1:3
         if k == 1 % Bias cases
            weights(1,k) = weights(1,k) + coeff*bias(1,1)*delta2_1;
            weights(2,k) = weights(2,k) + coeff*bias(1,2)*delta2_2;
            weights(3,k) = weights(3,k) + coeff*bias(1,3)*delta3_1;
         else % When k=2 or 3 input cases to neurons
            weights(1,k) = weights(1,k) + coeff*input(j,1)*delta2_1;
            weights(2,k) = weights(2,k) + coeff*input(j,2)*delta2_2;
            weights(3,k) = weights(3,k) + coeff*x2(k-1)*delta3_1;
         end
      end
   end  
end

Activation Function in NN

% Illustration of various activation functions used in NN's
x = -10:0.1:10;
tmp = exp(-x);
y1 = 1./(1+tmp);
y2 = (1-tmp)./(1+tmp);
y3 = x;
subplot(231); plot(x, y1); grid on;
axis([min(x) max(x) -2 2]);
title('Logistic Function');
xlabel('(a)');
axis('square');
subplot(232); plot(x, y2); grid on;
axis([min(x) max(x) -2 2]);
title('Hyperbolic Tangent Function');
xlabel('(b)');
axis('square');
subplot(233); plot(x, y3); grid on;
axis([min(x) max(x) min(x) max(x)]);
title('Identity Function');
xlabel('(c)');
axis('square');

Tuesday 5 April 2016

Implement defuzzyfication (Max-membership principle, Centroid method, Weighted average method)

clc;
clear all;
close all;

ip=11;
a1=1;
a2=5;
b1=4;
b2=7;
c1=7;
c2=9;
d2=11;
s1=0;
s2=0;

%Triangular function

for u=1:ip
    if(u<=a1)
        t(u)=0;
    elseif((u>a1)&&(u<=b1))
        t(u)=((u-a1)/(b1-a1));
    elseif((u>b1)&&(u<=c1))
        t(u)=((c1-u)/(c1-b1));
    else
        t(u)=0;
    end
end

subplot(221)
plot(t);
title('Triangular Function');

%Pie function

for u=1:ip
    if(u<=a2)
        p(u)=0;
    elseif((u>a2)&&(u<=b2))
        p(u)=((u-a2)/(b2-a2));
    elseif((u>b2)&&(u<=c2))
        p(u)=1;
    elseif((u>c2)&&(u<=d2))
        p(u)=((d2-u)/(d2-c2));
    else
        p(u)=0;
    end
end

subplot(222)
plot(p);
title('Pie Function');

z=t+p;
subplot(223);
plot(z);

%Using Centroid Method
for i=1:11
    s1=s1+(z(i)*i);
    s2=s2+z(i);
end

op1=s1/s2;
disp('Using Centroid Method:');
disp(op1);


%Using Weighted average method
a=mean(ip);
s1=s1+t(a)*(a)+p(a)*(a);
s2=s2+z(a)+p(a);
op1=s1/s2;
disp('Using Weighted Average MEthod');
disp(op1);

%Using Max-Membership Principle
k=z(1);
m=1;
for i=2:ip
    if(k<z(i))
    k=z(i);
    m=i;
    end
end
disp('Using Max Membership principle');
disp(m);

Monday 15 February 2016

Kohonen Self organizing feature map MATLAB code

clc;
clear all;
close all;
 
alpha=0.5;
x1=rand(1,100)-0.5;
x2=rand(1,100)-0.5;
x=[x1;x2];
 
w1=rand(1,50)-rand(1,50);
w2=rand(1,50)-rand(1,50);
w=[w1;w2];
 
figure(1);
plot([-0.5 0.5 0.5 -0.5 -0.5],[0.5 0.5 -0.5 -0.5 0.5]);
hold on;
plot(x1,x2,'b.');
axis([-1 1 -1 1]);
 
figure(2);
plot([-0.5 0.5 0.5 -0.5 -0.5],[0.5 0.5 -0.5 -0.5 0.5]);
hold on;
plot(w(1,:),w(2,:),'b.',w(1,:),w(2,:));
axis([-1 1 -1 1]);
hold off;
con=1;
ep=0;
while(con)
    for i=1:100
        for j=1:50
            d(j)=0;
            for k=1:2
                d(j)=d(j)+(w(k,j)-x(k,i))^2;
            end
        end
%         for j=1:50
%             if d(j)==min(d);
%                 J=j;
%             end
%         end
        [val J]=min(d);   
        I=J-1;
        K=J+1;
        
        if(I<1)
            I=50;
        end
        
        if(K>50)
            K=1;
        end
        
        w(:,J)=w(:,J)+alpha*(x(:,i)-w(:,J));
        w(:,I)=w(:,I)+alpha*(x(:,i)-w(:,I));
        w(:,K)=w(:,K)+alpha*(x(:,i)-w(:,K));
    end
    
    alpha=alpha-0.0049;
    ep=ep+1;
    plot([-0.5 0.5 0.5 -0.5 -0.5],[0.5 0.5 -0.5 -0.5 0.5]);
    hold on;
    plot(w(1,:),w(2,:),'b*',w(1,:),w(2,:));
    axis([-1 1 -1 1]);
    pause(0.1);
    hold off;
    if(ep==100)
        con=0;
    end
end
 
figure(3);
plot([-0.5 0.5 0.5 -0.5 -0.5],[0.5 0.5 -0.5 -0.5 0.5]);
hold on;
plot(w(1,:),w(2,:),'b.',w(1,:),w(2,:));
axis([-1 1 -1 1]);

Tuesday 2 February 2016

Implement perceptron for AND function using bipolar inputs

%Code

clc
clear all;
close all;

x1=[-1 -1 1 1];
x2=[-1 1 -1 1];
t=[-1 -1 -1 1];
alpha=input('Enter the value of alpha=');
th=input('enter the threshold=');
yin=zeros(1,4);
y=zeros(1,4);
w1=0;
w2=0;
b=0;
c=1;
cnt=0;
while(c)
    c=0
    for i=1:4
        %yin(i)=b+(x(i,1)*w1)+(x(i,2)*w2);
       yin(i)=b+(x1(i)*w1)+(x2(i)*w2);
        if yin(i)>th
            y(i)=1;
        else if yin(i)<-th
                y(i)=-1;
            else
                y(i)=0;
            end
            if t(i)~=y(i)
                w1=w1+(alpha*x1(i)*t(i));
                w2=w2+(alpha*x2(i)*t(i));
                b=b+(alpha*t(i));
                c=1;
            else
                w1=w1;
                w2=w2;
                b=b;
            end
        end
        cnt=cnt+1;
    end
    disp('OUTPUT MATRIX:');
    disp(y);
    disp('w1=');
    disp(w1);
    disp('w2=');
    disp(w2);
    disp('bias=');
    disp(b);
    a1=x1;
    a2=x2;
    a2=(-w1/w2)*a1-(b/w2);
    plot(x1,x2,'*r',a1,a2);
    axis([-2 2 -2 2]);
end

Wednesday 13 January 2016

Implement fuzzy membership functions (triangular, trapezoidal, gbell, PI, Gamma, Gaussian) ......... MATLAB Code

clc;
clear all;
close all;

ip=input('Enter input range : ');
a=input('Enter value of alpha : ');
b=input('Enter value of beta : ');
c=input('Enter value of gamma : ');
d=input('Enter value of delta : ');
m=input('Enter value of m : ');
del=input('Enter value of del : ');

%Gamma function

for u=1:ip
    if(u<=a)
        g(u)=0;
    elseif((u>a)&&(u<=b))
        g(u)=((u-a)/(b-a));
    else
        g(u)=1;
    end
end

subplot(2,3,1)
plot(g)
title('Gamma Function')
axis([0 ip 0 1]);

%S function

for u=1:ip
    if(u<=a)
        s(u)=0;
    elseif((u>a)&&(u<=b))
        s(u)=2*(((u-a)/(c-a))^2);
    elseif((u>b)&&(u<=c))
        s(u)=1-(2*(((u-c)/(c-a))^2));
    else
        s(u)=1;
    end
end


subplot(2,3,2)
plot(s);
title('S Function');
axis([0 ip 0 1]);

%Triangular function

for u=1:ip
    if(u<=a)
        t(u)=0;
    elseif((u>a)&&(u<=b))
        t(u)=((u-a)/(b-a));
    elseif((u>b)&&(u<=c))
        t(u)=((c-u)/(c-b));
    else
        t(u)=0;
    end
end

subplot(2,3,3)
plot(t);
title('Triangular Function');
axis([0 ip 0 1]);

%Pie function

for u=1:ip
    if(u<=a)
        p(u)=0;
    elseif((u>a)&&(u<=b))
        p(u)=((u-a)/(b-a));
    elseif((u>b)&&(u<=c))
        p(u)=1;
    elseif((u>c)&&(u<=d))
        p(u)=((d-u)/(d-c));
    else
        p(u)=0;
    end
end

subplot(2,3,4)
plot(p);
title('Pie Function');
axis([0 ip 0 1]);

%Gaussian function

for u=1:ip
   gs(u)=exp((-((u-m)^2))/(2*(del^2)));
end

subplot(2,3,5)
plot(gs);
title('Gaussian Function');
axis([0 ip 0 1]);

Monday 11 January 2016

Implement a simple linear regressor with a single neuron model .... MATLAB Code

// data.txt file


166, 54.00
195, 82.00
200, 72.00
260, 72.00
265, 90.00
335, 124.00
370, 94.00
450, 118.00


//    .m file for linear regression

%Load the data from our text file
data = load('/home/svcet/Desktop/data.txt');
% Define x and y
x = data(:,2);
y = data(:,1);
% Create a function to plot the data
function plotData(x,y)
plot(x,y,'rx','MarkerSize',8); % Plot the data
end
% Plot the data
plotData(x,y);
xlabel('Cost of Book'); % Set the x-axis label
ylabel('Number of Pages'); % Set the y-axis label
fprintf('Program paused. Press enter to continue.\n');
pause;
% Count how many data points we have
m = length(x);
% Add a column of all ones (intercept term) to x
X = [ones(m, 1) x];
% Calculate theta
theta = (pinv(X'*X))*X'*y
% Plot the fitted equation we got from the regression
hold on; % this keeps our previous plot of the training data visible
plot(X(:,2), X*theta, '-')
legend('Training data', 'Linear regression')
hold off % Don't put any more plots on this figure


MLP trained with Backpropagation for XOR Function.... MATLAB Code

function y=binsig(x)
y=1/(1+exp(-x));
end

function y=binsig1(x)
y=binsig(x)*(1-binsig(x));
end

%Back Propagation Network for XOR function with Binary Input and Output
clc;
clear;
%Initialize weights and bias
v=[0.197 0.3191 -0.1448 0.3394;0.3099 0.1904 -0.0347 -0.4861];
v1=zeros(2,4);
b1=[-0.3378 0.2771 0.2859 -0.3329];
b2=-0.1401;
w=[0.4919;-0.2913;-0.3979;0.3581];
w1=zeros(4,1);
x=[1 1 0 0;1 0 1 0];
t=[0 1 1 0];
alpha=0.02;
mf=0.9;
con=1;
epoch=0;
while con
    e=0;
    for I=1:4
        %Feed forward
        for j=1:4
            zin(j)=b1(j);
            for i=1:2
                zin(j)=zin(j)+x(i,I)*v(i,j);
            end
            z(j)=binsig(zin(j));
        end
        yin=b2+z*w;
        y(I)=binsig(yin);
        %Backpropagation of Error
        delk=(t(I)-y(I))*binsig1(yin);
        delw=alpha*delk*z'+mf*(w-w1);
        delb2=alpha*delk;
        delinj=delk*w;
        for j=1:4
            delj(j,1)=delinj(j,1)*binsig1(zin(j));
        end
        for j=1:4
            for i=1:2
                delv(i,j)=alpha*delj(j,1)*x(i,I)+mf*(v(i,j)-v1(i,j));
            end
        end
        delb1=alpha*delj;
        w1=w;
        v1=v;
        %Weight updation
        w=w+delw;
        b2=b2+delb2;
        v=v+delv;
        b1=b1+delb1';
        e=e+(t(I)-y(I))^2;
    end
    if e<0.005
        con=0;
    end
    epoch=epoch+1;
end
disp('BPN for XOR funtion with Binary input and Output');
disp('Total Epoch Performed');
disp(epoch);
disp('Error');
disp(e);
disp('Final Weight matrix and bias');
v
b1
w
b2