Detecting and preventing cyberattacks with anomaly detection and machine learning