-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (33 loc) · 1.45 KB
/
main.py
File metadata and controls
38 lines (33 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import training as tr
if __name__ == "__main__":
"""
Main entry point for training and evaluating the Perceptron model.
"""
while True:
input_data = input("Select dataset \n'1' for Iris Setosa x no Setosa; \n'2' for Iris Versicolor x Virginica; \n'3' for non linear Skin Cancer; \n'4' for linear Skin Cancer. \n'5' for exit\n")
if input_data == '1':
perceptron = tr.Perceptron(generated=False, linear=True)
elif input_data == '2':
perceptron = tr.Perceptron(generated=False, linear=False)
elif input_data == '3':
perceptron = tr.Perceptron(generated=True, linear=False)
elif input_data == '4':
perceptron = tr.Perceptron(generated=True, linear=True)
elif input_data == '5':
print("Exiting the program.")
break
else:
print("Invalid input. Please try again.")
continue
perceptron.plot_data()
perceptron.learning()
weights, error, accuracy, epochs, recall = perceptron.get_post_train(plot=True)
perceptron.cross_validate(plot=True)
predict = perceptron.think()
print("\nFinal Learned Weights:", weights)
print("Final Error:", error)
print("Number of epochs:", epochs)
print(f"Final Accuracy: {accuracy*100:.2f}%")
print(f"Final Recall: {recall*100:.2f}%")
print("\nPredictions Test:", predict)
perceptron.__del__()