code: def test_fit_predict(daily_data):
      """Checks fit and predict function with null model"""
      model = BaseSilverkiteEstimator(
          null_model_params={"strategy": "mean"}
      )
      train_df = daily_data["train_df"]
      test_df = daily_data["test_df"]
      assert model.last_predicted_X_ is None
      assert model.cached_predictions_ is None
  
      with pytest.raises(
          NotFittedError, match="Call `fit` before calling `predict`."
      ):
          model.predict(train_df)
  
      # Every subclass `fit` follows these steps
      model.fit(
          train_df, time_col=cst.TIME_COL, value_col=cst.VALUE_COL
      )
      # Checks that `df` is set, but other variables aren't
      assert_equal(model.df, train_df)
      assert model.pred_cols is None
      assert model.feature_cols is None
      assert model.coef_ is None
  
      with pytest.raises(
          ValueError,
          match="Must set `self.model_dict` before calling this function.",
      ):
          model.finish_fit()
  
      silverkite = SilverkiteForecast()
      model.model_dict = silverkite.forecast(
          df=train_df,
          time_col=cst.TIME_COL,
          value_col=cst.VALUE_COL,
          origin_for_time_vars=None,
          extra_pred_cols=None,
          train_test_thresh=None,
          training_fraction=None,
          fit_algorithm="linear",
          fit_algorithm_params=None,
          daily_event_df_dict=None,
          changepoints_dict=None,
          fs_components_df=pd.DataFrame(
              {
                  "name": ["tod", "tow", "conti_year"],
                  "period": [24.0, 7.0, 1.0],
                  "order": [3, 3, 5],
                  "seas_names": ["daily", "weekly", "yearly"],
              }
          ),
          autoreg_dict=None,
          min_admissible_value=None,
          max_admissible_value=None,
          uncertainty_dict=None,
      )
  
      with pytest.raises(
          NotFittedError,
          match="Subclass must call `finish_fit` inside the `fit` method.",
      ):
          model.predict(train_df)
      assert model.last_predicted_X_ is not None  # attempted prediction
      assert model.cached_predictions_ is None
  
      model.finish_fit()
      # Checks that other variables are set
      assert_equal(model.pred_cols, model.model_dict["pred_cols"])
      assert_equal(
          model.feature_cols, model.model_dict["x_mat"].columns
      )
      assert_equal(
          model.coef_,
          pd.DataFrame(
              model.model_dict["ml_model"].coef_,
              index=model.feature_cols,
          ),
      )
  
      # Predicts on a new dataset
      with LogCapture(cst.LOGGER_NAME) as log_capture:
          predicted = model.predict(test_df)
          assert_equal(model.last_predicted_X_, test_df)
          assert_equal(model.cached_predictions_, predicted)
          # The following message is from `SilverkiteForecast.predict` function,
          # which means the `predict` method is called and cached prediction is not used.
          log_capture.check(
              (
                  cst.LOGGER_NAME,
                  "DEBUG",
                  "``past_df`` not provided during prediction, use the ``train_df`` from "
                  "training results.",
              )
          )
  
      # Uses cached predictions
      with LogCapture(cst.LOGGER_NAME) as log_capture:
          assert_equal(model.predict(test_df), predicted)
          log_capture.check(
              (
                  cst.LOGGER_NAME,
                  "DEBUG",
                  "Returning cached predictions.",
              )
          )
  
      # Predicts on a different dataset
      with LogCapture(cst.LOGGER_NAME) as log_capture:
          predicted = model.predict(train_df)
          assert_equal(model.last_predicted_X_, train_df)
          assert_equal(model.cached_predictions_, predicted)
          # The following message is from `SilverkiteForecast.predict` function,
          # which means the `predict` method is called and cached prediction is not used.
          log_capture.check(
              (
                  cst.LOGGER_NAME,
                  "DEBUG",
                  "``past_df`` not provided during prediction, use the ``train_df`` from "
                  "training results.",
              )
          )
  
      # .fit() clears the cached result
      model.fit(
          train_df, time_col=cst.TIME_COL, value_col=cst.VALUE_COL
      )
      assert model.last_predicted_X_ is None
      assert model.cached_predictions_ is None
  
imports: import datetime
  import numpy
  import pandas
  import pytest
  from sklearn.exceptions import NotFittedError
  from sklearn.metrics import mean_absolute_error
  from sklearn.metrics import mean_squared_error
  from testfixtures import LogCapture
  import greykite.common.constants
  from greykite.algo.forecast.silverkite.forecast_silverkite import SilverkiteForecast
  from greykite.common.data_loader import DataLoader
  from greykite.common.features.timeseries_features import convert_date_to_continuous_time
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import daily_data_reg
  from greykite.common.testing_utils import generate_df_for_tests
  from greykite.common.testing_utils import generate_df_with_reg_for_tests
  from greykite.sklearn.estimator.base_silverkite_estimator import BaseSilverkiteEstimator
  from greykite.sklearn.estimator.testing_utils import params_component_breakdowns
  from greykite.sklearn.estimator.testing_utils import params_components
label_desc: Use image node_id 10 for calling a global function with example usage: test_fit_predict(daily_data) without return types