code: def test_fit_ml_model_with_uncertainty():
      """Tests fit_ml_model, with uncertainty intervals"""
      data = generate_test_data_for_fitting(
          n=1000, seed=41, heteroscedastic=False
      )
  
      df = data["df"]
      model_formula_str = data["model_formula_str"]
      y_test = data["y_test"]
      df_test = data["df_test"].reset_index(drop=True)
      fut_df = df_test.copy()
      fut_df["y"] = None
  
      trained_model = fit_ml_model(
          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_with_uncertainty(
          fut_df=fut_df, trained_model=trained_model
      )
      fut_df = pred_res["fut_df"]
      y_test_pred = fut_df["y"]
  
      err = calc_pred_err(y_test, y_test_pred)
      enum = EvaluationMetricEnum.MeanAbsoluteError
      assert err[enum.get_metric_name()] < 3.0
      enum = EvaluationMetricEnum.RootMeanSquaredError
      assert err[enum.get_metric_name()] < 3.0
      enum = EvaluationMetricEnum.Correlation
      assert err[enum.get_metric_name()] > 0.5
  
      # Tests if `fitted_df` returned is correct
      pred_res = predict_ml_with_uncertainty(
          fut_df=df, trained_model=trained_model
      )
  
      fitted_df_via_predict = pred_res["fut_df"]
      assert trained_model["fitted_df"].equals(fitted_df_via_predict)
  
      # Tests actual values for a smaller set
      expected_values = [
          8.36,
          11.19,
          1.85,
          15.57,
          16.84,
          14.44,
          21.07,
          9.02,
          1.81,
          -7.32,
      ]
      assert list(y_test_pred[:10].round(2)) == expected_values
  
      # calculate coverage of the CI
      # first add true values to fut_df
      fut_df["y_true"] = df_test["y"]
      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 (
          round(ci_coverage) == 95
      ), "95 percent CI coverage is not as expected"
  
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 18 for calling a global function with example usage: test_fit_ml_model_with_uncertainty() without return types