Nonlinearity Mitigation Using a Machine Learning Detector Based on k-Nearest Neighbors