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
# plot | |
fig_forecast = model.plot(forecast) | |
fig_components = model.plot_components(forecast) | |
fig_model = model.plot_parameters() |
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
# model and fit D= clander days freq | |
model = NeuralProphet() | |
metrics = model.fit(apple_features, | |
freq='D', epochs=1000) | |
#predict | |
forecast = model.predict(apple_features) |
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
# 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"}) |
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 |
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
import numpy as np | |
import pandas as pd | |
from sklearn import preprocessing | |
from sklearn.model_selection import train_test_split | |
# Reading and converting Date | |
data = pd.read_csv('AAPL.csv') | |
data['Date'] = pd.to_datetime(data['Date'], infer_datetime_format=True) | |
data.info() |
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
### Create the Stacked LSTM model | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Dense,Dropout | |
from tensorflow.keras.layers import LSTM | |
from tensorflow.keras.initializers import RandomNormal, Constant | |
import tensorflow as tf | |
# Set random seed for reproducibility: get the same result after each time running the model | |
tf.random.set_seed(1234) | |
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
### with spliting train and test | |
m = NeuralProphet() | |
df_train, df_test = m.split_df(apple_features, valid_p=0.3,freq='D') | |
# fiting | |
metricss = m.fit(df_train, validation_df=df_test , freq='D',epochs=1000) | |
# predict | |
forecast = model.predict(df_train) |
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 |
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
### Create the Bidirectional LSTM model | |
from random import random | |
from numpy import array | |
from numpy import cumsum | |
from keras.models import Sequential | |
from tensorflow.keras.layers import Dense,Dropout | |
from keras.layers import TimeDistributed | |
from keras.layers import Bidirectional | |
from tensorflow.keras.layers import LSTM |
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
import numpy as np | |
import pandas as pd | |
from sklearn import preprocessing | |
from sklearn.model_selection import train_test_split | |
# Reading and converting Date | |
data = pd.read_csv('AAPL.csv') | |
data['Date'] = pd.to_datetime(data['Date'], infer_datetime_format=True) | |
data.info() |
NewerOlder