[Spark-3525] Adding gradient boosting

Check whether index is out of bound