finish the predict function of ex2