| | |
| | """Vecna.159 |
| | |
| | Automatically generated by Colab. |
| | |
| | Original file is located at |
| | https://colab.research.google.com/drive/1gX09qWUyT9sTqHSCPCRbeAU3veDQ9KOC |
| | """ |
| |
|
| | !pip install neuralprophet |
| |
|
| | import numpy as np |
| | import pandas as pd |
| | import matplotlib.pyplot as plt |
| | from neuralprophet import NeuralProphet |
| |
|
| | import warnings |
| | warnings.filterwarnings('ignore') |
| |
|
| | import os |
| | for dirname, _, filenames in os.walk('/content/Meta Dataset.csv'): |
| | for filename in filenames: |
| | print(os.path.join(dirname, filename)) |
| |
|
| | df = pd.read_csv('/content/Meta Dataset.csv') |
| |
|
| | df.head() |
| |
|
| | df.info() |
| |
|
| | df['Date'] = pd.to_datetime(df['Date']) |
| |
|
| | df.dtypes |
| |
|
| | df = df[['Date', 'Close']] |
| |
|
| | df.head() |
| |
|
| | df.columns = ['ds', 'y'] |
| |
|
| | df.head() |
| |
|
| | plt.plot(df['ds'], df['y'], label='actual', c='g') |
| | plt.title('Meta Stock Prices Over TIme') |
| | plt.xlabel('Date') |
| | plt.ylabel('Stock Price') |
| | plt.show() |
| |
|
| | model = NeuralProphet( |
| | batch_size=16 |
| | ) |
| |
|
| | model.fit(df) |
| |
|
| | future = model.make_future_dataframe(df, periods=365) |
| |
|
| | forecast = model.predict(future) |
| | forecast |
| |
|
| | actual_prediction = model.predict(df) |
| |
|
| | plt.plot(df['ds'], df['y'], label='actual', c='g') |
| | plt.plot(actual_prediction['ds'], actual_prediction['yhat1'], label='prediction_actual', c='r') |
| | plt.plot(forecast['ds'], forecast['yhat1'], label='future_prediction', c='b') |
| | plt.xlabel('Date') |
| | plt.ylabel('Stock Price') |
| | plt.legend() |
| |
|
| | plt.show() |
| |
|
| | model.plot_components(forecast) |