fit_data_model

fit_data_model(covid19_region_data: pandas.core.frame.DataFrame, model: lmfit.model.Model, data_set: str = 'confirmed', init_params: dict = {}, free_var_name: str = 'x') → Dict[str, Union[lmfit.model.ModelResult, pandas.core.frame.DataFrame]][source]

Generic function to fit lmfit.Model models, onto a regional subset covid data.

Parameters
  • covid19_region_data (pd.DataFrame) – covid19 DataFrame for one region

  • model (lmfit.Model) – [description]

  • data_set (str, optional) – which subdata schold be fitted, need to be of value [“confirmed” | “recovered” | deaths], by default “confirmed”

  • init_params (dict, optional) – initial parameters for a fit, they depend on the model, by default {}

  • free_var_name (str, optional) – name of the free variable used by the model, by default “x”

Returns

Result dict with keys “model_result” and “plot_data”.

model_result: lmfit.model.ModelResult

result of the fit, with optimized parameters

plot_data: pd.DataFrame

Same as covid19_region_data, but with an resetted index and and added fir result

Return type

Dict[str, Union[lmfit.model.ModelResult, pd.DataFrame]]