Closure for machine learning