Last active
January 5, 2022 18:35
-
-
Save A-safarji/afa048c9a0eb522a4d510067215be264 to your computer and use it in GitHub Desktop.
NeuralProphet Forcasting
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
# install neuralprophet | |
!pip install neuralprophet | |
# import libraries | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import plotly.offline as py | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
# import neuralprophet | |
from neuralprophet import NeuralProphet | |
# read data | |
df1 = pd.read_csv("stock.csv") | |
df1.head() | |
# select Date and Adj Close from the dataset | |
df2 = df1[['Date','Adj Close']] | |
df2.tail() | |
# change names to fit NeuralProphet req | |
apple_features = df2.rename(columns = {"Date":"ds","Adj Close":"y"}) | |
apple_features.head() | |
# model and fit D= clander days freq | |
model = NeuralProphet() | |
metrics = model.fit(apple_features, | |
freq='D', epochs=1000) | |
#predict | |
forecast = model.predict(apple_features) | |
# plot | |
fig_forecast = model.plot(forecast) | |
fig_components = model.plot_components(forecast) | |
fig_model = model.plot_parameters() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment