Advertisement
dondonondon

Proses Test

Nov 21st, 2020 (edited)
1,356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.40 KB | None | 0 0
  1. procedure fnProsesTest(st : Boolean = False);
  2. var ii, jj, kk, nn, i, xx: integer;
  3.     CT, Y2, net, D2, deltaB2, MSEchek, Denorm, y: Double;
  4.     error, sumError, PE, sumPE, aa, bb, MAPE: Double;
  5.     CP, Y1, D1, deltaW1, deltaW2, deltaB1, D1_net: array of array of Double;
  6.     Baris, Kolom: Word;
  7.     themp: array of array of Double;
  8.     jmlParam, minus : Integer;
  9.     SQLAdd : String;
  10. begin
  11.   if st then begin
  12.     //fnSetData(True);
  13.     fnLoadBW;
  14.   end;
  15.  
  16.   if sTest then
  17.     Exit;
  18.  
  19.   sTest := True;
  20.   try
  21.     SetLength(Y2akhirTest, tUji, 2);
  22.     for kk:= 0 to tUji - 1 do begin
  23.       SetLength(CP, 1, nodeInput);
  24.       for Kolom:= 0 to nodeInput - 1 do
  25.         CP[0, Kolom]:= dtUjiNorm[kk, Kolom];
  26.  
  27.       CT:= dtUjiNorm[kk, kolTarget-1];
  28.  
  29.       SetLength(themp, 1, nodeInput);
  30.       SetLength(Y1, 1, nodeHidden);
  31.  
  32.       for ii:= 0 to nodeHidden-1 do begin
  33.         net:= 0;
  34.         for kolom:= 0 to nodeInput - 1 do
  35.         begin
  36.           themp[0, Kolom]:= CP[0, Kolom] * w1[ii, Kolom];
  37.           net:= net + themp[0, Kolom];
  38.         end;
  39.  
  40.         net:= net + b1[ii, 0];
  41.         Y1[0, ii]:= 1/(1+exp(-net));
  42.       end;
  43.  
  44.       SetLength(themp, 1, nodeHidden);
  45.       for ii:= 0 to nodeOutput - 1 do
  46.       begin
  47.         net:= 0;
  48.         for Kolom:= 0 to nodeHidden - 1 do
  49.         begin
  50.           themp[0, Kolom]:= Y1[0, Kolom] * w2[ii, Kolom];
  51.           net:= net + themp[0, Kolom];
  52.         end;
  53.         net:= net + b2;
  54.         Y2:= 1/(1+exp(-net));
  55.       end;
  56.       Y2akhirTest[kk, 0]:= CT;
  57.       Y2akhirTest[kk, 1]:= Y2;
  58.     end;
  59.  
  60.     if st then begin
  61.       try
  62.         DM.Conn.StartTransaction;
  63.         for i := 0 to tUji - 1 do begin
  64.           Denorm := Y2akhirTest[i, 1];
  65.           Denorm := (((Denorm - 0.1) * (vMax - vMin)) + (0.8 * vMin)) / 0.8;
  66.  
  67.           if Denorm < 0.5 then
  68.             SQLAdd := 'Tidak Pesan'
  69.           else
  70.             SQLAdd := 'Pesan';
  71.  
  72.           SQLAdd :=
  73.             Format(
  74.               'INSERT INTO tbl_prediksi (id_parameter, id_data, status) VALUES (%s, %s, %s)',
  75.               [
  76.               QuotedStr(transIDCheck),
  77.               QuotedStr(arrID[i]),
  78.               QuotedStr(SQLAdd)
  79.               ]
  80.             );
  81.  
  82.           fnSQLAdd(DM.QTemp1, SQLAdd, True);
  83.           fnExecSQL(DM.QTemp1);
  84.         end;
  85.  
  86.         DM.Conn.Commit;
  87.       except
  88.         DM.Conn.Rollback;
  89.       end;
  90.     end;
  91.   finally
  92.     sTest := False;
  93.   end;
  94. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement