Browse Source

added ARIMA method

master
杨浩然 4 years ago
parent
commit
32a001e08e
6 changed files with 160 additions and 160 deletions
  1. BIN
      COVID-19/Prediction/.vs/Prediction/v16/.suo
  2. +1
    -1
      COVID-19/Prediction/Prediction.sln
  3. +7
    -7
      COVID-19/Prediction/Prediction/ARIMA.py
  4. +2
    -2
      COVID-19/Prediction/Prediction/ARIMA.pyproj

BIN
COVID-19/Prediction/.vs/Prediction/v16/.suo View File


+ 1
- 1
COVID-19/Prediction/Prediction.sln View File

@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "Holt_Winters", "Prediction\Holt_Winters.pyproj", "{FE4194E6-8A95-4B93-968D-ED4305D7F944}"
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "Holt_Linear_Trend", "Prediction\Holt_Linear_Trend.pyproj", "{3F8A3B3F-C79E-412C-8EE4-DA8FF5DB31A6}"
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "ARIMA", "Prediction\ARIMA.pyproj", "{3F8A3B3F-C79E-412C-8EE4-DA8FF5DB31A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

COVID-19/Prediction/Prediction/Holt_Linear_Trend.py → COVID-19/Prediction/Prediction/ARIMA.py View File

@ -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)

COVID-19/Prediction/Prediction/Holt_Linear_Trend.pyproj → COVID-19/Prediction/Prediction/ARIMA.pyproj View File

@ -11,7 +11,7 @@
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<Name>Holt_Linear_Trend</Name>
<Name>ARIMA</Name>
<RootNamespace>ARIMA</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@ -23,7 +23,7 @@
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Compile Include="Holt_Linear_Trend.py" />
<Compile Include="ARIMA.py" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
<!-- Uncomment the CoreCompile target to enable the Build command in

Loading…
Cancel
Save