use ffill in forecasting example

This commit is contained in:
Chi Wang 2022-03-31 18:06:24 +00:00
parent 84f1ae7424
commit e877de6414
3 changed files with 6 additions and 7 deletions

View File

@ -152,13 +152,11 @@
"outputs": [],
"source": [
"import statsmodels.api as sm\n",
"data = sm.datasets.co2.load_pandas()\n",
"data = data.data\n",
"data = sm.datasets.co2.load_pandas().data\n",
"# data is given in weeks, but the task is to predict monthly, so use monthly averages instead\n",
"data = data['co2'].resample('MS').mean()\n",
"data = data.fillna(data.bfill()) # makes sure there are no missing values\n",
"data = data.to_frame().reset_index()\n",
"# data = data.rename(columns={'index': 'ds', 'co2': 'y'})"
"data = data.bfill().ffill() # makes sure there are no missing values\n",
"data = data.to_frame().reset_index()"
]
},
{

View File

@ -8,7 +8,8 @@ def test_forecast_automl(budget=5):
data = sm.datasets.co2.load_pandas().data["co2"].resample("MS").mean()
data = (
data.fillna(data.bfill())
data.bfill()
.ffill()
.to_frame()
.reset_index()
.rename(columns={"index": "ds", "co2": "y"})

View File

@ -247,7 +247,7 @@ import statsmodels.api as sm
data = sm.datasets.co2.load_pandas().data
# data is given in weeks, but the task is to predict monthly, so use monthly averages instead
data = data['co2'].resample('MS').mean()
data = data.fillna(data.bfill()) # makes sure there are no missing values
data = data.bfill().ffill() # makes sure there are no missing values
data = data.to_frame().reset_index()
num_samples = data.shape[0]
time_horizon = 12