fork download
  1. import numpy as np
  2. import pandas as pd
  3. from statsmodels.tsa.arima.model import ARIMA
  4. import matplotlib.pyplot as plt
  5.  
  6. # Historical sequence data
  7. sequence_data = [
  8. 304,300,302,294,294,294,294,298,298,294,298,296,304,300,308,308,306,318,324,324,324,322,324,322,322,322,334,338,330,330,336,332,330,326,334,330,324,322,326,322,326,326,334,328,326,338,384,374,358,364,344,348,336,344,338,336,334,346,346,344,354,352,348,350,344,344,340,340,358,360,360,354,372,390,410,402,402,394,394,394,418,408,402,408,408,406,396,394,406,410,404,404,404,406,404,416,404,414,410,412,412,410,432,458,492,515,492,500,470,490,545,525,550,555,600,585,610,520,565,575,695,680,605,630,630,615,590,605,655,655,685,695,685,650,650,670,670,675,700,695,705,695,680,665,650,670,645,620,630,620,635,620,615,595,585,575,605,590,590,590,590,605,600,600,585,595,590,590,575,580,565,560,560,540,525,550,560,540,520,510,510,510,525,545,540,530,515,515,515,500,494,474,476,496,496,496,498,486,468,488,496,500,492,484,486,480,468,474,486,494,488,488,484,486,494,490,494,520,500,498,498,535,515,500,510,525,500,488,474,478,480,480,480,484,484,480,488,490,490,494,500,505,505,500,492,498,500,500,500,505,500,498,500,490,488,486,486,484,482,482,482,480,476,476,478,476,470,472,476,476,478,480,480,484,490,492,498,498,494,492,488,484,486,490,492,496,492,492,500,510,505,505,510,540,525,520,510,496,510,505,510,520,505,505,500,488,492,494,500,498,492,490,496,492,488,490,486,476
  9. ]
  10.  
  11. # Convert the sequence data to a pandas Series
  12. sequence_series = pd.Series(sequence_data)
  13.  
  14. # Fit an ARIMA model
  15. arima_model = ARIMA(sequence_series, order=(5,1,0)) # Adjust the order as needed
  16. arima_fit = arima_model.fit()
  17.  
  18. # Make predictions for the next 3 values
  19. forecast = arima_fit.forecast(steps=3)
  20.  
  21. # Print the predicted values
  22. print("Predicted values for the next 3 steps:", forecast)
  23.  
  24. # Plot the original data along with the forecasted values
  25. plt.figure(figsize=(10, 6))
  26. plt.plot(sequence_series, label='Original Data')
  27. plt.plot(pd.Series(forecast, index=[len(sequence_series), len(sequence_series)+1, len(sequence_series)+2]), label='Forecasted Data', linestyle='--')
  28. plt.title('ARIMA Forecasting')
  29. plt.xlabel('Index')
  30. plt.ylabel('Sequence Value')
  31. plt.legend()
  32. plt.grid(True)
  33. plt.show()
  34.  
Success #stdin #stdout #stderr 0.27s 40912KB
stdin
1
stdout
Standard output is empty
stderr
Error: unexpected symbol in "import numpy"
Execution halted