Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.96 KB | None | 0 0
  1. load Ionosphere;
  2. X = Ionosphere(:,1:34);
  3. Y = Ionosphere(:,35);
  4. Acc_CV = zeros(10,1);
  5. indeksy = crossvalind('Kfold', Y, 10);
  6.  
  7. col=2;
  8. a=1;
  9.     for i = 2:70
  10.         i
  11.         for k = 1:10
  12.             test_k = (indeksy == k);
  13.             train_k =~test_k;
  14.             X_test = X(test_k,:);
  15.             Y_test = Y(test_k,:);
  16.             X_train = X(train_k,:);
  17.             Y_train = Y(train_k,:);
  18.             % Uczenie i walidacja sieci:
  19.             net = feedforwardnet(i);
  20.             net.trainFcn = 'trainoss';
  21.             net.trainParam.epochs=500;
  22.             net.trainParam.showWindow=false;
  23.             net = train(net, X_train', Y_train');
  24.             Y_Out = round(sim(net, X_test'));
  25.             % Wyznaczenie dokładności
  26.             Acc_CV(k) = 1 - sum(abs(Y_Out - Y_test'))/length(Y_test);
  27.         end
  28.  
  29.         Acc_Final= mean(Acc_CV)
  30.         Acc_Final_Tab_Epochs(a,1) = i;
  31.         Acc_Final_Tab_Epochs(a,2)= Acc_Final;
  32.         a=a+1;
  33.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement