IIS_2023_1/kondrashin_mikhail_lab_6/funcClassifier.py

13 lines
509 B
Python
Raw Normal View History

2023-11-26 23:23:30 +04:00
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import accuracy_score
def random_state_fit(i, x_train, y_train, x_test, y_test, func):
mlp = MLPClassifier(random_state=i, max_iter=4000, n_iter_no_change=10,
activation=func, alpha=0.01, hidden_layer_sizes=[100, 100])
mlp.fit(x_train, y_train)
predictions = mlp.predict(x_test)
acc_mlp = accuracy_score(y_test, predictions)
print(f"Func {func} with accuracy {acc_mlp} \n")
return acc_mlp