Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Applied Deep Learning with Keras

You're reading from   Applied Deep Learning with Keras Solve complex real-life problems with the simplicity of Keras

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher
ISBN-13 9781838555078
Length 412 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Ritesh Bhagwat Ritesh Bhagwat
Author Profile Icon Ritesh Bhagwat
Ritesh Bhagwat
Mahla Abdolahnejad Mahla Abdolahnejad
Author Profile Icon Mahla Abdolahnejad
Mahla Abdolahnejad
Matthew Moocarme Matthew Moocarme
Author Profile Icon Matthew Moocarme
Matthew Moocarme
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

About the Book
About the Authors
Learning Objectives
Audience
Approach
Hardware Requirements
Software Requirements
Conventions
Installation and Setup
Installing the Code Bundle
Additional Resources
1. Introduction to Machine Learning with Keras FREE CHAPTER 2. Machine Learning versus Deep Learning 3. Deep Learning with Keras 4. Evaluate Your Model with Cross-Validation using Keras Wrappers 5. Improving Model Accuracy 6. Model Evaluation 7. Computer Vision with Convolutional Neural Networks 8. Transfer Learning and Pre-Trained Models 9. Sequential Modeling with Recurrent Neural Networks 1. Appendix

Chapter 9: Sequential Modeling with Recurrent Neural Networks

Activity 17: Predict the Trend of Microsoft’s Stock Price Using an LSTM with 50 Units (Neurons)

Solution

  1. Import the required libraries:

    import numpy as np

    import matplotlib.pyplot as plt

    import pandas as pd

  2. Import the dataset:

    dataset_training = pd.read_csv(‘MSFT_train.csv’)

    dataset_training.head()

    The following figure shows the output of the preceding code:

    Figure 9.23: The first five rows of the dataset
  3. We are going to make the prediction using the Open stock price, so we will extract this column first:

    training_data = dataset_training.iloc[:, 1:2].values

    training_data

    The following figure shows the output of the preceding code:

    Figure 9.24: The extracted column (the open stock price) from the dataset
  4. Then, perform feature scaling by normalizing the data:

    from sklearn.preprocessing import MinMaxScaler

    sc = MinMaxScaler(feature_range = (0, 1))

    training_data_scaled = sc.fit_transform(training_data)

    training_data_scaled...

lock icon The rest of the chapter is locked
arrow left Previous Section
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images