 clear all;
 close all;

 %Two-classesinputdatasets
 hw1=csvread(hardwood.csv);
 cp1=csvread(carpet.csv);

 %Thefirsttwofeaturesareused
 tw1=hw1(:,1); tw2=hw1(:,2);
 tw3=sqrt(tw1.*tw1+tw2.*tw2);
 figure;plot(tw1,tw2,.);grid on
 axis([-300 300 -300 300]);

 tp1=cp1(:,1); tp2=cp1(:,2);
 tp3=sqrt(tp1.*tp1+tp2.*tp2);
 hold on;plot(tp1,tp2,r.);grid on;
 axis([-300 300 -300 300]);


 % Labels are added
 yy=[ones(1,size(tw3,1)) zeros(1,size(tp3,1))];
 xx=[tw3;tp3];


 % Finding the best split using information gain
 [slx,fmx,igx]=uca_calc_ig_fn(xx,yy);

 fmxsort=sort(fmx,descend);
 tmp1=find(fmx==fmxsort(1));
 f1=tmp1(1);
 fval=xx(f1,slx(f1));


 % Splitting the circular domain
 idxL=find(xx(f1,:)<fval);
 idxR=find(xx(f1,:)>=fval);

 xxL=xx(:,idxL);
 xxR=xx(:,idxR);
 yyL=yy(idxL);
 yyR=yy(idxR);


% Showing the classification counts
 fprintf(\n);
 fprintf(Left side class 1 = %d\n,sum(yyL));
 fprintf(Left side class 0 = %d\n\n,length(yyL)-sum(yyL));

 fprintf(Right side class 1 = %d\n,sum(yyR));
 fprintf(Right side class 0 = %d\n,length(yyR)-sum(yyR));


 % Showing the classes using circles
 figure;
 for ii=1:size(xx,2)
   if yy(ii)==1
     circle(0,0,xx(f1,ii),.,0.01);
   else
     circle(0,0,xx(f1,ii),r.,0.01);
   end
   hold on;grid on;
 end


 %Showing the overlapping region
 figure;
 for ii=1:size(xx,2)
  if yy(ii)==1
    circle(0,0,xx(f1,ii),.,0.01);
  else
    circle(0,0,xx(f1,ii),r.,0.09);
  end
  hold on;grid on;
end