Upload vecna_159.py
Browse files- vecna_159.py +71 -0
vecna_159.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""Vecna.159
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colab.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1gX09qWUyT9sTqHSCPCRbeAU3veDQ9KOC
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
!pip install neuralprophet
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
import pandas as pd
|
| 14 |
+
import matplotlib.pyplot as plt
|
| 15 |
+
from neuralprophet import NeuralProphet
|
| 16 |
+
|
| 17 |
+
import warnings
|
| 18 |
+
warnings.filterwarnings('ignore')
|
| 19 |
+
|
| 20 |
+
import os
|
| 21 |
+
for dirname, _, filenames in os.walk('/content/Meta Dataset.csv'):
|
| 22 |
+
for filename in filenames:
|
| 23 |
+
print(os.path.join(dirname, filename))
|
| 24 |
+
|
| 25 |
+
df = pd.read_csv('/content/Meta Dataset.csv')
|
| 26 |
+
|
| 27 |
+
df.head()
|
| 28 |
+
|
| 29 |
+
df.info()
|
| 30 |
+
|
| 31 |
+
df['Date'] = pd.to_datetime(df['Date'])
|
| 32 |
+
|
| 33 |
+
df.dtypes
|
| 34 |
+
|
| 35 |
+
df = df[['Date', 'Close']]
|
| 36 |
+
|
| 37 |
+
df.head()
|
| 38 |
+
|
| 39 |
+
df.columns = ['ds', 'y']
|
| 40 |
+
|
| 41 |
+
df.head()
|
| 42 |
+
|
| 43 |
+
plt.plot(df['ds'], df['y'], label='actual', c='g')
|
| 44 |
+
plt.title('Meta Stock Prices Over TIme')
|
| 45 |
+
plt.xlabel('Date')
|
| 46 |
+
plt.ylabel('Stock Price')
|
| 47 |
+
plt.show()
|
| 48 |
+
|
| 49 |
+
model = NeuralProphet(
|
| 50 |
+
batch_size=16
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
model.fit(df)
|
| 54 |
+
|
| 55 |
+
future = model.make_future_dataframe(df, periods=365)
|
| 56 |
+
|
| 57 |
+
forecast = model.predict(future)
|
| 58 |
+
forecast
|
| 59 |
+
|
| 60 |
+
actual_prediction = model.predict(df)
|
| 61 |
+
|
| 62 |
+
plt.plot(df['ds'], df['y'], label='actual', c='g')
|
| 63 |
+
plt.plot(actual_prediction['ds'], actual_prediction['yhat1'], label='prediction_actual', c='r')
|
| 64 |
+
plt.plot(forecast['ds'], forecast['yhat1'], label='future_prediction', c='b')
|
| 65 |
+
plt.xlabel('Date')
|
| 66 |
+
plt.ylabel('Stock Price')
|
| 67 |
+
plt.legend()
|
| 68 |
+
|
| 69 |
+
plt.show()
|
| 70 |
+
|
| 71 |
+
model.plot_components(forecast)
|