Advertisement
fensa08

Untitled

Sep 8th, 2020
1,656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 30.70 KB | None | 0 0
  1. '__main__':
  2.     warnings.filterwarnings('ignore', category=ConvergenceWarning)
  3.  
  4.     learning_rate = float(input())
  5.     epochs = int(input())
  6.     train_x, train_y, test_x, test_y = divide_set(data)
  7.  
  8.     # probaj go ova so epochs namesto max_iter
  9.     klasifikator = MLPClassifier(6, activation="tanh", max_iter=epochs, learning_rate_init=learning_rate,
  10.                                  random_state=0)
  11.     klasifikator.fit(train_x, train_y)
  12.  
  13.     train_acc = 0
  14.     prediction = klasifikator.predict(train_x)
  15.     for pred, ele in zip(prediction, train_y):
  16.         if pred == ele:
  17.             train_acc += 1
  18.  
  19.     test_acc = 0
  20.     prediction = klasifikator.predict(test_x)
  21.     for pred, ele in zip(prediction, test_y):
  22.         if pred == ele:
  23.             test_acc += 1
  24.  
  25.     train_acc = train_acc / len(train_x)
  26.     test_acc = test_acc / len(test_x)
  27.  
  28.     if (int((train_acc - test_acc) * 100 > 15)):
  29.         print("Se sluchuva overfitting")
  30.     else:
  31.         print("Ne se sluchuva overfitting")
  32.  
  33.     print("Tochnost so trenirachko mnozhestvo:", train_acc)
  34.     print("Tochnost so validacisko mnozhestvo:", test_acc)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement