title: How to write a for loop for multiple machine learning metrics if one metric requires a parameter specification?
body: <p>I created a <code>for loop</code> for generating metrics on my train and test set. However, in order to calculated <code>Root Mean Square Error</code> (RMSE), I need to either 1) take the <code>sqrt</code> of <code>Mean Square Error</code> or 2) set the parameter <code>mean_squared_error(squared = False)</code>. However, I only want a parameter for the RMSE, not for the MAE or the R2.</p>
  <p>If I try the below I, understandably, get an error <code>TypeError: mean_squared_error() missing 2 required positional arguments: 'y_true' and 'y_pred'</code> because the parentheses should only come in the <code>for loop</code>.</p>
  <pre><code>from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_error
  
  #Metrics on train and test
  metrics = {
      'RMSE' : mean_squared_error,
      'MAE' : mean_absolute_error,
      'R2' : r2_score
  }
      #Train and Test
  for key in metrics:
      i = metrics[key]
      train_score = i(y_train, train_predictions)
      test_score = i(y_test, y_pred)
      print(f'Train set {key}: {train_score:.4f}')
      print(f'Test set {key}: {test_score:.4f}')
  </code></pre>