diff --git a/perceptron/perceptron.m b/perceptron/perceptron.m index 20a0487..348a619 100644 --- a/perceptron/perceptron.m +++ b/perceptron/perceptron.m @@ -14,8 +14,8 @@ mnx=-0.1*mxx;%for visualization %mnx = min(X(1,:)); mxy = max(X(2,:)); mny=-0.1*mxy; % for visualization %mny = min(X(2,:)); -figure; -ginput(1); +%%% figure; +%%% ginput(1); err = 1; round = 0; while err > 0 @@ -24,17 +24,17 @@ while err > 0 w = w + rate*X(:,ii) * Y(ii); %then add (or subtract) this point to w x1=mnx:0.01:mxx; x2=-(w(1)*x1+w(3))/w(2); - %figure; - clf; - hold on - plot(X(1,pos_idx),X(2,pos_idx),'b*','MarkerSize',10); - plot(X(1,neg_idx),X(2,neg_idx),'r+','MarkerSize',10); - plot(X(1,ii),X(2,ii),'ko','MarkerSize',15); - plot(x1,x2); - xlim([mnx mxx]); - ylim([mny mxy]); + %%% figure; + %%% clf; + %%% hold on + %%% plot(X(1,pos_idx),X(2,pos_idx),'b*','MarkerSize',10); + %%% plot(X(1,neg_idx),X(2,neg_idx),'r+','MarkerSize',10); + %%% plot(X(1,ii),X(2,ii),'ko','MarkerSize',15); + %%% plot(x1,x2); + %%% xlim([mnx mxx]); + %%% ylim([mny mxy]); %ginput(1); - pause(0.5); %change the delay + % pause(0.5); %change the delay end end round = round + 1 diff --git a/zoo/zoo2.m b/zoo/zoo2.m new file mode 100644 index 0000000..4c98ede --- /dev/null +++ b/zoo/zoo2.m @@ -0,0 +1,26 @@ +% Change K here to any integer < 96 +K = 60; + +load zoo; %load matlab data +sample_idxs = randperm(96, K) +sample_data = trn_data(sample_idxs, : ) +sample_lab = trn_lab(sample_idxs, : ) +t = fitctree(sample_data,sample_lab,'PredictorNames', fields); %train a decision tree for classification +view(t,'Mode','graph'); %visualize the tree t + +% %for visualization +% allHandles=findall(groot,'Type','text') +% set(allHandles,'FontSize',24) +% pause; +% h = findall(groot,'Type','figure'); +% close(h); +% for i=1:6 +% clf(gcf); +% imshow(strcat(tst_names{i},'.png')); +% set(gcf,'Position',[0 0 700 700]+300); +% title(tst_names{i},'FontSize',40); +% pause; +% y=predict(t,tst_data(i,:)); %classify a test sample by tree t +% title(sprintf('%s is %s',tst_names{i},y{1}),'FontSize',40,'color', 'r'); +% pause; +% end \ No newline at end of file