Scikit Learn Machine Learning Tutorial for investing with Python p. 10
Key Takeaways
This video demonstrates how to label data for machine learning using Scikit-learn and Python, specifically for investing by comparing stock performance to the S&P 500 index. It covers data preparation, normalization, and visualization using Python libraries such as Pandas and Matplotlib.
Full Transcript
what's going on guys welcome to Part 10 of our machine learning with scikit learn and python and a whole bunch of other things actually anyway uh what we're going to be doing in this video is um actually labeling our data so like I was saying and you've probably seen now the most uh intensive part of machine learning is just getting the data and structuring the data normally izing the data which we still have yet to do because we only have one feature so we don't really need to normalize it too much um but uh all of those things just take up so much time and now what we're going to do is go ahead and label this data and this labeling will will ring true no matter how many features we have the first thing I want to go ahead and show is um you know performance- Wise um kind of an interesting concept really that um I find is you know can we prove or disprove the idea of momentum investing even um and so a lot of people support momentum investing investing and historically I haven't uh but my findings here are actually quite interesting so anyways let's let's go ahead and get started um so we're going to we've got difference and then now we're going to add one new thing to our data frame and that's going to be uh status and at every step of the way we're going to ask um what is the status is it outperform or underperform uh compared to to the starting value um so we've got status here and and eventually what we could do is we could store the previous value and then we could say from you know the last data point we had Did they perform underperform or outperform and all of this and then you'll see in a little bit here we're going to have a kind of another dichotomy that will happen and and that's you know should we consider every step of the way out performing and Performing or like just in general where did they end up um so more a lot more on that later um but uh so for now we've got status okay and now what we do is we're going to come down to where we're calculating percentage change which is right here and let's add a couple more variables first of all we're going to we're going to go ahead and just Define difference so difference where we kind of had hardcoded it um so we're going to do that and then we'll just call this difference here difference and then we'll come over here difference equals that and then we're also going to um do the following we're going to say if uh difference is greater than zero this means our status is out actually seems to be in quotes uh outperform um and then else status equals under perform okay so uh again different is just the percentage change for the stock minus percentage change of the S&P 500 if that's greater than zero it means it has outperformed if it's less than zero uh it means that it's underperformed so now we're going to add one more down here now and we do status and status is equivalent to status easy enough now we're going to come down to where we're graphing this stuff and basically really need to add that Legend price last that's kind of inefficient but anyways uh within this try and accept here um we're just going to do the following so before we actually plot um basically right here we're going to ask the following question we're going to say if plore uh DF status and then we're going to ask the the negative Firth element which means the last element if that equals under per underperform let's learn to type here uh we're going to say color equals R for red else color equals g for green we plot we're saying label equals each uh ticker and then we're going to go ahead and comma and we're going to say color equals color easy enough um so that will plot it and again this will be plotting the the lines based on the final value um it's quite difficult well actually I mean it's a little more difficult um to change the lines's color like midline it is possible to do um and maybe I'll show that down the road but uh for now we're not going to deal with that and let's just let's just look real quickly at a stock um now wait for it okay so so we get this you know large plot here um and we can see okay there's Apple just doing its thing outperforming like crazy let's go ahead and just zoom in and kind of ignore Apple for now and so here we can kind of see that you know once out once an outperformer almost always an outperformer but some of these companies did kind of underperform for a little bit and then as time went on they moved on to outperform um and then some of these just right at the last second outperform um but we can see some of the companies that initially strongly outperformed died died to back down and that was probably um people who maybe overleveraged stuff like that um anyway but for the most part I mean just looking at this we can kind of see that for the most part outperformers outperform and underperformers underperform um but later on we will um we're going to do both most likely because I'm very curious to see which is the superior method um but we will F at first we'll just start with their ending value right um or [Music] actually not really sure I I think we we end up doing both I'm not really sure how I'm going to start it off either but with underperform and overperform basically we've now labeled this company as either a buy or a sell and so we've got our label and that can be translated as a zero or a one and so now our D data is labeled and we need to learn um how we can now take this data and we can do machine learning on this data and um so we're going to save that now for the not next video um but in the next video we'll actually um I believe be covering actual you know machine learning in an actual example so anyways very exciting stay tuned for that um I realized we actually already did Cover a machine learning example but now with the knowledge you have you have your own data the previous machine learning example you didn't have your own data so it's a little harder there's a bit of a disconnect there as far as what all the data you know parts are uh so in this next video you'll uh at least see linear uh SBC um in an example of how to do that so anyways uh stay tuned for that if you have any questions or comments on this video please do feel free to leave them below um otherwise as always thanks for watching thanks for all the support and the subscriptions and until next time [Music]
Original Description
In this machine learning with Scikit-learn tutorial video, we cover how to label our data. Our stocks are either over-performers, having out-performed the S&P 500 index, or they are under-performers, having under-performed against the S&P 500 index.
sample code: http://pythonprogramming.net
http://seaofbtc.com
http://sentdex.com
http://hkinsley.com
https://twitter.com/sentdex
Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
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: ML Pipelines
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
How to Learn a Hard Technical Skill Without Burning Out
Dev.to · Anas Kalthoum | FreeBrain
After interviewing over 100 ML Candidates. Last Week Someone Walked In and Made Me Take Notes.
Medium · Machine Learning
How AI Learns with Less Labeled Data
Medium · Machine Learning
Mastering TypeScript — Understanding the TypeScript Compiler (tsc) from Scratch — Lesson 2
Medium · JavaScript
🎓
Tutor Explanation
DeepCamp AI