Separated function to calculate model performance