wrote some pseudo for trainParams algorithm