Machine Learning for QoS Optimization in Early Attack Detection Networks