class_docstr: The lag based estimator, using lagged observations with aggregation functions
  to forecast the future. This estimator includes the common week-over-week estimation method.
  
  The algorithm support specifying the following:
  
      lag_unit : the unit to calculate lagged values. One of the values in
          `~greykite.sklearn.estimator.lag_based_estimator.LagUnitEnum`.
      lags : a list of lags indicating which lagged ``lag_unit`` data are used in prediction.
          For example, [1, 2] indicating using the past two ``lag_unit`` same time data.
      agg_func : the aggregation function used over the lagged observations.
      agg_func_params : extra parameters used for ``agg_func``.
  
  
  When certain lags are not available, extra data will be extrapolated.
  When predicting into the future and future data is not available,
  predicted values will be used.
  
  Parameters
  ----------
  freq : `str` or None, default None
      The data frequency, used to validate lags.
  lag_unit : `str`, default "week"
      The unit to calculate lagged observations.
      Available options are in `~greykite.sklearn.estimator.lag_based_estimator.LagUnitEnum`.
  lags : `list` [`int`] or None, default None
      The lags in ``lag_unit``'s. [1, 2] indicates using the past two ``lag_unit`` same time values.
      If not provided, the default is to use lag 1 observation only.
  agg_func : `str` or callable, default "mean"
      The aggregation functions used over lagged observations.
  agg_func_params : `dict` or None, default None
      Extra parameters used for ``agg_func``.
  uncertainty_dict: `dict` or None, default None
      How to fit the uncertainty model.
      See `~greykite.sklearn.uncertainty.uncertainty_methods.UncertaintyMethodEnum`.
      If not provided but ``coverage`` is given, this falls back to
      `~greykite.sklearn.uncertainty.simple_conditional_residuals_model.SimpleConditionalResidualsModel`.
  past_df : `pandas.DataFrame` or None, default None
      The past data used to append to the training data.
      If not provided the past data needed will be interpolated.
  series_na_fill_func : `callable` or None, default `lambda s: s.bfill().ffill()`
      The function to fill NAs when they exist.
  
  Attributes
  ----------
  df : `pandas.DataFrame` or None
      The fitted and interpolated training data.
  uncertainty_model : any or None
      The trained uncertainty model.
  max_lag_order : `int` or None
      The maximum lag order.
  min_lag_order : `int` or None
      The minimum lag order.
  train_start : `pandas.Timestamp` or None
      The training start timestamp.
  train_end : `pandas.Timestamp` or None
      The training end timestamp.
class_docstr_tok: ["The","lag","based","estimator",",","using","lagged","observations","with","aggregation","functions","to","forecast","the","future",".","This","estimator","includes","the","common","week-over-week","estimation","method",".","The","algorithm","support","specifying","the","following",":","lag_unit",":","the","unit","to","calculate","lagged","values",".","One","of","the","values","in","`","~greykite.sklearn.estimator.lag_based_estimator.LagUnitEnum","`",".","lags",":","a","list","of","lags","indicating","which","lagged","``","lag_unit","``","data","are","used","in","prediction",".","For","example",",","[","1",",","2","]","indicating","using","the","past","two","``","lag_unit","``","same","time","data",".","agg_func",":","the","aggregation","function","used","over","the","lagged","observations",".","agg_func_params",":","extra","parameters","used","for","``","agg_func","``",".","When","certain","lags","are","not","available",",","extra","data","will","be","extrapolated",".","When","predicting","into","the","future","and","future","data","is","not","available",",","predicted","values","will","be","used",".","Parameters","--","--","--","--","--","freq",":","`","str","`","or","None",",","default","None","The","data","frequency",",","used","to","validate","lags",".","lag_unit",":","`","str","`",",","default","``","week","''","The","unit","to","calculate","lagged","observations",".","Available","options","are","in","`","~greykite.sklearn.estimator.lag_based_estimator.LagUnitEnum","`",".","lags",":","`","list","`","[","`","int","`","]","or","None",",","default","None","The","lags","in","``","lag_unit","``","'s",".","[","1",",","2","]","indicates","using","the","past","two","``","lag_unit","``","same","time","values",".","If","not","provided",",","the","default","is","to","use","lag","1","observation","only",".","agg_func",":","`","str","`","or","callable",",","default","``","mean","''","The","aggregation","functions","used","over","lagged","observations",".","agg_func_params",":","`","dict","`","or","None",",","default","None","Extra","parameters","used","for","``","agg_func","``",".","uncertainty_dict",":","`","dict","`","or","None",",","default","None","How","to","fit","the","uncertainty","model",".","See","`","~greykite.sklearn.uncertainty.uncertainty_methods.UncertaintyMethodEnum","`",".","If","not","provided","but","``","coverage","``","is","given",",","this","falls","back","to","`","~greykite.sklearn.uncertainty.simple_conditional_residuals_model.SimpleConditionalResidualsModel","`",".","past_df",":","`","pandas.DataFrame","`","or","None",",","default","None","The","past","data","used","to","append","to","the","training","data",".","If","not","provided","the","past","data","needed","will","be","interpolated",".","series_na_fill_func",":","`","callable","`","or","None",",","default","`","lambda","s",":","s.bfill","(",")",".ffill","(",")","`","The","function","to","fill","NAs","when","they","exist",".","Attributes","--","--","--","--","--","df",":","`","pandas.DataFrame","`","or","None","The","fitted","and","interpolated","training","data",".","uncertainty_model",":","any","or","None","The","trained","uncertainty","model",".","max_lag_order",":","`","int","`","or","None","The","maximum","lag","order",".","min_lag_order",":","`","int","`","or","None","The","minimum","lag","order",".","train_start",":","`","pandas.Timestamp","`","or","None","The","training","start","timestamp",".","train_end",":","`","pandas.Timestamp","`","or","None","The","training","end","timestamp","."]
docstr: Gets the number of rounds of predictions needed.
  
  For example, when the prediction is 3 weeks while the lag is 1 week,
  it will need to make prediction for the first week in the first round.
  Then it uses the predictions of the first week to predict the second week, etc.
  The number of rounds here is 3.
  
  If the prediction period is within training or at most ``self.lag_unit_delta`` * ``self.min_lag_order``
  more than the training period, then just one round is needed.
  
  Parameters
  ----------
  pred_df : `pandas.DataFrame`
      The prediction df with ``self.time_col_``.
  
  Returns
  -------
  n_rounds : `int`
      The number of rounds of predictions needed.
docstr_tok: ["Gets","the","number","of","rounds","of","predictions","needed",".","For","example",",","when","the","prediction","is","3","weeks","while","the","lag","is","1","week",",","it","will","need","to","make","prediction","for","the","first","week","in","the","first","round",".","Then","it","uses","the","predictions","of","the","first","week","to","predict","the","second","week",",","etc",".","The","number","of","rounds","here","is","3",".","If","the","prediction","period","is","within","training","or","at","most","``","self.lag_unit_delta","``","*","``","self.min_lag_order","``","more","than","the","training","period",",","then","just","one","round","is","needed",".","Parameters","--","--","--","--","--","pred_df",":","`","pandas.DataFrame","`","The","prediction","df","with","``","self.time_col_","``",".","Returns","--","--","--","-","n_rounds",":","`","int","`","The","number","of","rounds","of","predictions","needed","."]
code: def _get_n_rounds(self, pred_df: pd.DataFrame):
      """Gets the number of rounds of predictions needed.
  
      For example, when the prediction is 3 weeks while the lag is 1 week,
      it will need to make prediction for the first week in the first round.
      Then it uses the predictions of the first week to predict the second week, etc.
      The number of rounds here is 3.
  
      If the prediction period is within training or at most ``self.lag_unit_delta`` * ``self.min_lag_order``
      more than the training period, then just one round is needed.
  
      Parameters
      ----------
      pred_df : `pandas.DataFrame`
          The prediction df with ``self.time_col_``.
  
      Returns
      -------
      n_rounds : `int`
          The number of rounds of predictions needed.
      """
      train_end = self.train_end
      step_size = self.lag_unit_delta * self.min_lag_order
      pred_end = pred_df[self.time_col_].max()
      n_rounds = 1
      while train_end + step_size < pred_end:
          train_end += step_size
          n_rounds += 1
      return n_rounds
  
imports: from enum import Enum
  from typing import List
  from typing import Optional
  from typing import Union
  import numpy
  import pandas
  from dateutil.relativedelta import relativedelta
  from sklearn.metrics import mean_squared_error
  from greykite.common import constants
  from greykite.common.aggregation_function_enum import AggregationFunctionEnum
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.common.time_properties import fill_missing_dates
  from greykite.common.time_properties import infer_freq
  from greykite.sklearn.estimator.base_forecast_estimator import BaseForecastEstimator
label_desc: Use image node_id 8 for calling the LagBasedEstimator obj's underlying member method code with example usage: obj._get_n_rounds(pred_df) and returns: n_rounds