code: def test_fit_ml_model_with_evaluation_with_uncertainty():
      """Tests fit_ml_model_with_evaluation with uncertainty intervals"""
      df = gen_sliced_df(
          sample_size_dict={
              "a": 200,
              "b": 340,
              "c": 300,
              "d": 8,
              "e": 800,
          },
          seed_dict={
              "a": 301,
              "b": 167,
              "c": 593,
              "d": 893,
              "e": 191,
              "z": 397,
          },
          err_magnitude_coef=8.0,
      )
  
      df = df[["x", "z_categ", "y_hat"]]
      df.rename(columns={"y_hat": "y"}, inplace=True)
      model_formula_str = "y~x+z_categ"
      y_col = "y"
      # test_df
      fut_df = df.copy()
      # we change the name of the column of true values in fut_df
      # to be able to keep track of true values later
      fut_df.rename(columns={"y": "y_true"}, inplace=True)
      y_test = fut_df["y_true"]
      # create a small dataframe for testing values only
      small_sample_index = [1, 500, 750, 1000]
  
      trained_model = fit_ml_model_with_evaluation(
          df=df,
          model_formula_str=model_formula_str,
          uncertainty_dict={
              "uncertainty_method": "simple_conditional_residuals",
              "params": {
                  "quantiles": [0.025, 0.975],
                  "quantile_estimation_method": "normal_fit",
                  "sample_size_thresh": 10,
                  "small_sample_size_method": "std_quantiles",
                  "small_sample_size_quantile": 0.8,
              },
          },
      )
  
      pred_res = predict_ml(fut_df=fut_df, trained_model=trained_model)
      fut_df = pred_res["fut_df"]
      y_test_pred = fut_df[y_col]
  
      y_test_pred_small = y_test_pred[small_sample_index]
  
      # testing predictions
      err = calc_pred_err(y_test, y_test_pred)
      enum = EvaluationMetricEnum.MeanAbsoluteError
      assert err[enum.get_metric_name()] < 10.0
      enum = EvaluationMetricEnum.RootMeanSquaredError
      assert err[enum.get_metric_name()] < 10.0
      enum = EvaluationMetricEnum.Correlation
      assert err[enum.get_metric_name()] > 0.5
  
      # testing actual values for a smaller set
      assert list(y_test_pred_small.round(1)) == [
          99.7,
          201.5,
          303.5,
          7.3,
      ], "predictions are not correct"
  
      # Testing uncertainty
      # Assigns the predicted y to the response in fut_df
      fut_df["y"] = y_test_pred
      new_df_with_uncertainty = predict_ci(
          fut_df, trained_model["uncertainty_model"]
      )
      assert list(new_df_with_uncertainty.columns) == list(
          fut_df.columns
      ) + [
          QUANTILE_SUMMARY_COL,
          ERR_STD_COL,
      ], "column names are not as expected"
      fut_df[QUANTILE_SUMMARY_COL] = new_df_with_uncertainty[
          QUANTILE_SUMMARY_COL
      ]
  
      # Calculates coverage of the CI
      fut_df["inside_95_ci"] = fut_df.apply(
          lambda row: (
              (row["y_true"] <= row[QUANTILE_SUMMARY_COL][1])
              and (row["y_true"] >= row[QUANTILE_SUMMARY_COL][0])
          ),
          axis=1,
      )
  
      ci_coverage = 100.0 * fut_df["inside_95_ci"].mean()
      assert (
          94.0 < ci_coverage < 96.0
      ), "95 percent CI coverage is not between 94 and 96"
  
      # testing uncertainty_method not being implemented but passed
      with pytest.raises(
          Exception,
          match="uncertainty method: non_existing_method is not implemented",
      ):
          fit_ml_model_with_evaluation(
              df=df,
              model_formula_str=model_formula_str,
              uncertainty_dict={
                  "uncertainty_method": "non_existing_method",
                  "params": {
                      "quantiles": [0.025, 0.975],
                      "quantile_estimation_method": "normal_fit",
                      "sample_size_thresh": 10,
                      "small_sample_size_method": "std_quantiles",
                      "small_sample_size_quantile": 0.8,
                  },
              },
          )
  
imports: import warnings
  import numpy
  import pandas
  import pytest
  import scipy
  from pandas.testing import assert_frame_equal
  from patsy import dmatrices
  from greykite.algo.common.ml_models import breakdown_regression_based_prediction
  from greykite.algo.common.ml_models import design_mat_from_formula
  from greykite.algo.common.ml_models import fit_ml_model
  from greykite.algo.common.ml_models import fit_ml_model_with_evaluation
  from greykite.algo.common.ml_models import fit_model_via_design_matrix
  from greykite.algo.common.ml_models import get_h_mat
  from greykite.algo.common.ml_models import get_intercept_col_from_design_mat
  from greykite.algo.common.ml_models import predict_ml
  from greykite.algo.common.ml_models import predict_ml_with_uncertainty
  from greykite.algo.uncertainty.conditional.conf_interval import predict_ci
  from greykite.common.constants import ERR_STD_COL
  from greykite.common.constants import QUANTILE_SUMMARY_COL
  from greykite.common.constants import TimeFeaturesEnum
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.evaluation import calc_pred_err
  from greykite.common.features.timeseries_features import build_time_features_df
  from greykite.common.features.timeseries_features import fourier_series_multi_fcn
  from greykite.common.features.timeseries_features import get_fourier_col_name
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import gen_sliced_df
label_desc: Use image node_id 22 for calling a global function with example usage: test_fit_ml_model_with_evaluation_with_uncertainty() without return types