Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '__main__':
- x_1 = int(input())
- x_2 = int(input())
- # 1
- test_set_1 = dataset[:x_1]
- test_x_1 = [x[:-1] for x in test_set_1]
- test_y_1 = [x[-1] for x in test_set_1]
- train_set_1 = dataset[x_1:]
- train_x_1 = [x[:-1] for x in train_set_1]
- train_y_1 = [x[-1] for x in train_set_1]
- # 2
- test_set_2 = dataset[:x_2]
- test_x_2 = [x[:-1] for x in test_set_2]
- test_y_2 = [x[-1] for x in test_set_2]
- train_set_2 = dataset[x_2:]
- train_x_2 = [x[:-1] for x in train_set_2]
- train_y_2 = [x[-1] for x in train_set_2]
- classifier_1 = MLPClassifier(3, activation='relu', learning_rate_init=0.003, max_iter=200, random_state=0)
- classifier_2 = MLPClassifier(3, activation='relu', learning_rate_init=0.003, max_iter=200, random_state=0)
- classifier_1.fit(train_x_1, train_y_1)
- classifier_2.fit(train_x_2, train_y_2)
- accuracy_1 = 0
- for i in range(0, len(test_set_1)):
- predict = classifier_1.predict([test_x_1[i]])
- if predict[0] == test_set_1[i][-1]:
- accuracy_1 += 1
- final_acc_1 = accuracy_1 / len(test_set_1)
- print(f"Tochnost model1: {final_acc_1}")
- accuracy_2 = 0
- for i in range(0, len(test_set_2)):
- predict = classifier_2.predict([test_x_2[i]])
- if predict[0] == test_set_2[i][-1]:
- accuracy_2 += 1
- final_acc_2 = accuracy_2 / len(test_set_2)
- print(f"Tochnost model2: {final_acc_2}")
- if final_acc_1 > final_acc_2:
- print("Prviot model ima pogolema tochnost")
- elif final_acc_2 > final_acc_1:
- print("Vtoriot model ima pogolema tochnost")
- else:
- print("Dvata modeli imaat ednakva tochnost")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement