Created
March 5, 2020 09:23
-
-
Save geniusnhu/14f79c20460b6b4afe396ddd584f5ca2 to your computer and use it in GitHub Desktop.
Auto Arima
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Split train and test | |
train = Wal_sales.iloc[:106,1].values | |
test = Wal_sales.iloc[106:,1].values | |
# Train the model | |
stepwise_model.fit(train) | |
# Predict test set | |
pred = stepwise_model.predict(n_periods=37) | |
# Reframe the data | |
test_pred = Wal_sales.iloc[106:,:2] | |
test_pred["Predict_sales"] = np.array(pred,dtype="float") | |
# Visualize the prediction | |
plt.figure(figsize=(12,8)) | |
plt.plot( 'Date', 'Weekly_Sales', data=Wal_sales, markersize=12, color='olive', linewidth=3) | |
plt.plot( 'Date', 'Predict_sales', data=test_pred, marker='', color='blue', linewidth=3) | |
plt.title("Predicted sales vs Actual sales") | |
plt.legend() | |
print("MAPE score: ", mean_absolute_percentage_error(test, pred)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment