code: def score_catboost_model(catboost_parameters, update_defaults=False):
      r2_values = []
      rmse_values = []
      catboost_parameters.update(DEFAULT_PARAMETERS)
      for train_index, test_index in kf.split(df):
          train_pool = Pool(
              df.iloc[train_index].drop(["price_usd"], 1),
              label=df.iloc[train_index].price_usd,
              cat_features=categorical_features_names,
          )
          test_pool = Pool(
              df.iloc[test_index].drop(["price_usd"], 1),
              label=df.iloc[test_index].price_usd,
              cat_features=categorical_features_names,
          )
          model = CatBoost(catboost_parameters)
          model.fit(train_pool, verbose=False)
          r2_values.append(
              r2_score(
                  df.iloc[test_index].price_usd.values,
                  model.predict(test_pool),
              )
          )
          rmse_values.append(
              mean_squared_error(
                  df.iloc[test_index].price_usd.values,
                  model.predict(test_pool),
                  squared=False,
              )
          )
      if update_defaults:
          DEFAULT_MODEL_METRICS["R2"] = np.mean(r2_values)
          DEFAULT_MODEL_METRICS["RMSE"] = np.mean(rmse_values)
          print(
              "R2 score: {:.4f}({:.4f})".format(
                  np.mean(r2_values), np.std(r2_values)
              )
          )
          print(
              "RMSE score: {:.0f}({:.0f})".format(
                  np.mean(rmse_values), np.std(rmse_values)
              )
          )
      else:
          DEFAULT_MODEL_R2 = DEFAULT_MODEL_METRICS["R2"]
          DEFAULT_MODEL_RMSE = DEFAULT_MODEL_METRICS["RMSE"]
          r2_change = (
              100
              * (np.mean(r2_values) - DEFAULT_MODEL_R2)
              / DEFAULT_MODEL_R2
          )
          rmse_change = (
              100
              * (np.mean(rmse_values) - DEFAULT_MODEL_RMSE)
              / DEFAULT_MODEL_RMSE
          )
          print(
              "R2 score: {:.4f}({:.4f}) {:+.1f}% compared to default parameters".format(
                  np.mean(r2_values), np.std(r2_values), r2_change
              )
          )
          print(
              "RMSE score: {:.0f}({:.0f}) {:+.1f}% compared to default parameters".format(
                  np.mean(rmse_values), np.std(rmse_values), rmse_change
              )
          )
      return model.get_all_params()
  
file_path: catboost/catboost/pytest/smoke_tests/categorical_features_parameters_gpu.py
imports: import os
  import numpy
  import pandas
  import seaborn
  from sklearn.metrics import r2_score, mean_squared_error
  from sklearn.model_selection import KFold
  from pathlib import Path
label_desc: Use image node_id 1 for calling a global function with example usage: score_catboost_model(catboost_parameters, update_defaults) and returns: model