machine learning : ex4 completed, spent a whole night !!