|
|
@ -36,13 +36,13 @@ yCNARIMA = testCN.copy() |
|
|
|
yUSARIMA = testUS.copy() |
|
|
|
|
|
|
|
#训练模型 |
|
|
|
fitCNconfirmed = sm.tsa.statespace.SARIMAX(trainCN.Confirmed).fit() |
|
|
|
fitCNrecovered = sm.tsa.statespace.SARIMAX(trainCN['Recovered']).fit() |
|
|
|
fitCNdeaths = sm.tsa.statespace.SARIMAX(trainCN['Deaths']).fit() |
|
|
|
fitCNconfirmed = sm.tsa.statespace.SARIMAX(trainCN['Confirmed'],trend='c').fit() |
|
|
|
fitCNrecovered = sm.tsa.statespace.SARIMAX(trainCN['Recovered'],trend='c').fit() |
|
|
|
fitCNdeaths = sm.tsa.statespace.SARIMAX(trainCN['Deaths'],trend='ct').fit() |
|
|
|
|
|
|
|
fitUSconfirmed = sm.tsa.statespace.SARIMAX(trainUS.Confirmed,trend='ct').fit() |
|
|
|
fitUSrecovered = sm.tsa.statespace.SARIMAX(trainUS['Recovered']).fit() |
|
|
|
fitUSdeaths = sm.tsa.statespace.SARIMAX(trainUS['Deaths']).fit() |
|
|
|
fitUSconfirmed = sm.tsa.statespace.SARIMAX(trainUS['Confirmed'],trend='ct').fit() |
|
|
|
fitUSrecovered = sm.tsa.statespace.SARIMAX(trainUS['Recovered'],trend='ct').fit() |
|
|
|
fitUSdeaths = sm.tsa.statespace.SARIMAX(trainUS['Deaths'],trend='ct').fit() |
|
|
|
|
|
|
|
#测试 |
|
|
|
yCNARIMA['SARIMAconfirmed'] = fitCNconfirmed.predict(start="2020-11-01", end="2020-12-09", dynamic=True) |
|
|
@ -65,7 +65,7 @@ forecastCNARIMA['deathsPred'] = fitCNdeaths.predict(start="2020-12-10", end="202 |
|
|
|
forecastUSARIMA['Date'] = pd.to_datetime(forecastUSARIMA['Date'], format='%Y/%m/%d').values.astype('datetime64[h]') |
|
|
|
forecastUSARIMA['confirmedPred'] = fitUSconfirmed.predict(start="2020-12-10", end="2020-12-16", dynamic=True) |
|
|
|
forecastUSARIMA['recoveredPred'] = fitUSrecovered.predict(start="2020-12-10", end="2020-12-16", dynamic=True) |
|
|
|
forecastUSARIMA['deathsPred'] = fitUSdeaths.predict(start="2020-12-10", end="2020-12-16", dynamic=True) |
|
|
|
forecastUSARIMA['deathsPred'] = fitUSdeaths.predict(start="2020-12-10", end="2020-12-16", dynamic=False) |
|
|
|
|
|
|
|
#RMSE |
|
|
|
rmseCNARIMACon = pow(mean_squared_error(np.asarray(testCN['Confirmed']), np.asarray(yCNARIMA['SARIMAconfirmed'])),0.05) |