Forecasting Apple stock price data
We have now covered everything we need to know about time series for the TensorFlow Developer Certificate exam. Let us round off this chapter and the book with a real-world use case on time series. For this exercise, we will be working with a real-world dataset (Apple closing day stock price). Let’s see how we can do this next. The Jupyter notebook for this exercise can be found here: https://github.com/PacktPublishing/TensorFlow-Developer-Certificate-Guide. Let’s begin:
- We start by importing the required libraries:
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow import keras
import yfinance as yf
Here, we are using a new library called
yfinance
. This lets us access the Apple stock data for our case study.
Note
You may want to run pip install yfinance
to get it working if the import fails.
- Create a DataFrame:
df_apple = yf.Ticker(tickerSymbol)
df_apple = df_apple.history(period...