Separate the dense and sparse case in predict