Balancing RNN sequence data - Deep Learning w/ Python, TensorFlow and Keras p.10
Key Takeaways
This video tutorial demonstrates how to balance RNN sequence data for a cryptocurrency price prediction model using Python, TensorFlow, and Keras. The tutorial covers data preprocessing, balancing, and splitting into training and validation sets.
Full Transcript
what is going on everybody and welcome to another deep learning with Python tensorflow and Cara's tutorial video in this video we're gonna continue building on our a future crypto currency price movement predictor recurrent neural network okay so where we left off we've got this pre-processing happening we've built the sequential data and we've separated out our validation data we have we normalized the data here we scaled the data here the next thing we need to do is balance the data we need to have as many byes as we have cells if you have any more like if you're like 52% buys and 50 want 52% buys and let's say 48 percent cells let's make sure it adds up to a hundred if you're if you have data like that it's probably ok you probably need to worry about balancing it but if you've got anything more than like a 60/40 split or even more egregious it's really important you balance your data set and arguably it's just always gonna be better if you just balance it because the the model is gonna learn probably pretty quickly if there's like a 510 percent Delta there that oh just always break this one class and immediately we make huge improvement and that's the easiest change that the model can make so it's important that you have a perfect split and imbalance of your data so that the model doesn't waste time doing that and then also kind of get stuck in a rut like it's gonna start doing that and then from there it might stay stuck and lost and so you don't want that to happen now there is a way you can pass class waits to care us and tell it like hey one example of this is worth 1.5 examples of this or something like that and you can tell it hey wait these a little different when you go to calculate the loss for mistakes made and stuff but to be honest I've not found that to solve balanced issues so I think that's a great idea in theory it just doesn't seem to work so anyway balance your data so so that's what we're gonna do now we've shelled the data and now what we want to do is actually you know balance it so what we're gonna do is and again there's probably better way to do this but I'm just gonna have two lists here we're gonna say buys as a list and sells is a list clear that out we're gonna zoom in a little bit okay then we're gonna say is for sequence targets in sequential data if Tarija is a zero that's a cell so then what we're gonna say is cells not append sequence target Elif target equals a1 bys append sequence and target okay um so now we have buys and sells the next thing we want to do is before we start slicing things and dicing things we're gonna go ahead and do a random shuffle buys and dot shuffle cells we probably don't really need to do that because we've already shuffled here but shuffle for good measure so so then what we're gonna find out is which one is lesser we don't actually need to know if it's by ourselves we just need to know what's the minimum value of these two lists so the way we can do that is lower equals the minimum of the Len of buys or the Len of cells and that'll tell us you know like maybe by cz's 30,000 in cells a 60,000 well lower would be 30,000 then what we can say is buys equals buys up to or I'm sorry let's see uh how do we do this up yeah up to lower so if the Len is 30k it would say up to 30,000 buys and then sells equals sells up to lower I'm gonna remove 30k because that's not true I don't think it's just a value okay okay so now we've got that so then we're gonna say sequential data now actually is just equal to byes plus the cells and then random dot shuffle sequential data why are we doing that shuffle again at least this one is so like the data isn't all byes than all cells cuz that'll really confuse the model you definitely want to shuffle it up okay so now we've got that what we need to do is now it's in sequential data we need to convert it from you know it's bison cells is containing the guitar you know the features and the labels what we want to do now is split those out to be you know the X's and Y's as diff you know as different lists I guess because the way that we're gonna feed it you know it's going to be a model dot fit XY so we have to split these out into X's and Y's so we're gonna say x equals a list y equals a list and then we're gonna iterate over the sequential data so full sequence targets in sequential data we're gonna say capital X can we type dot append the sequence and then Y dot append the targets okay at this point I think we're closing in on being complete we're going to return the number array of x and y so our pre-processing data frame function should be complete and now we're ready to do is come on down here and comment out that uncomment those get rid of this and I think what I want to do is let's print out some statistics I'm not sure I really want to type all this out I'm not going to I'm gonna copy and paste this from the text-based version of this tutorial this is just wastes Aria but my dog so long I think our trash people are here and they're making a bunch of noise oh no we got a huge I have no idea what's going on someone's putting a ladder up to my roof I probably should be somewhat concerned okay it's so the so what we can see is the training data is 69,000 validation is 3000 there's a good balance between the buys and the don't buys in that we have a balance between the validation buys and don't buys so everything is nicely balanced we've got it split apart the way that we're expecting to and in the next tutorial I think we are ready to build the model and train the model so that's what we're going to do in the next video if you've got questions comments concerns whatever you know the deal feel free to leave them below otherwise I will see you guys in the next video
Original Description
Welcome to the next part of our Deep Learning with Python, TensorFlow, and Keras tutorial series. In this tutorial, we're going to continue building our cryptocurrency-price-predicting Recurrent Neural Network.
Text tutorials and sample code: https://pythonprogramming.net/balancing-rnn-data-deep-learning-python-tensorflow-keras/
Discord: https://discord.gg/sentdex
Support the content: https://pythonprogramming.net/support-donate/
Twitter: https://twitter.com/sentdex
Facebook: https://www.facebook.com/pythonprogramming.net/
Twitch: https://www.twitch.tv/sentdex
G+: https://plus.google.com/+sentdex
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: Sequence Models
View skill →Related Reads
📰
📰
📰
📰
Understanding Deep Learning Through Four Interactive Experiments
Medium · Data Science
Understanding Deep Learning Through Four Interactive Experiments
Medium · Deep Learning
Optimizers in Deep Learning: From Gradient Descent to Adam
Medium · Deep Learning
The Meta-Architecture of Interface Fracture: High-Dimensional Logical Stress and Systemic Collapse…
Medium · Deep Learning
🎓
Tutor Explanation
DeepCamp AI