Predicting Stock Prices with LSTMs: One Mistake Everyone Makes (Episode 16)

  Рет қаралды 88,420

Lazy Programmer

Lazy Programmer

Күн бұрын

Пікірлер: 118
@MZak-js7oy
@MZak-js7oy 2 жыл бұрын
You pinpointed exactly what I was wondering about. As a person who worked in the financial market for more than a decade and just learned ML. Min-Max scaling was a big question mark for me. First you never know what is the max of a certain price especially in a market (like gold) is always doing higher highs. Also, minimum price is not actually known throughout the data set, so unless you are a bank who has 80-150 years of recorded data for minimum, your data set size will never reflect the true lows or true highs. this leads that most ML models in YT tutorials just plainly panic and fails when the price is doing new historical highs or lows (according to the data set it was trained on, not actual historical highs or lows). scaling and standardization is crucial no doubts, but MinMax technique is fundamentally wrong and reflects absolutely an ignorance about the market dynamics and the core principles of training a ML model.
@digitalnomad2196
@digitalnomad2196 11 ай бұрын
just normalize the data, also to his point if anyone has an actual edge why post it online. If he has an edge and makes millions why youtube and why courses eh ?
@sanchuro7140
@sanchuro7140 10 ай бұрын
On top of your points, some tutorials even fit min-max scaler to both train and test . This is sooooo wrong that using future data to fit the scaler. Most of the tutorials are really just trash.
@emye35
@emye35 29 күн бұрын
you nailed it on the head
@adwaitdathanr4040
@adwaitdathanr4040 3 жыл бұрын
This video is a gem. I saw a lot of blogs and tutorials repeating the mistakes you had mentioned.
@azrulfyz1162
@azrulfyz1162 3 жыл бұрын
could you please add a link to where I could find those topic, much appreciated. Thanks
@vohemiq
@vohemiq 2 жыл бұрын
This video is so underrated. I happen to see the same errors. I would also advise that instead of using a min-max scaler, to use a power transform and standardize.
@anoriginalnick
@anoriginalnick 3 жыл бұрын
I believe it's important to keep things in the same scale because the algorithms apply the same learning rate to all feature dimensions.
@ahmedhamza3939
@ahmedhamza3939 11 ай бұрын
it's important for models who based in estimating weights using gradient because you will most likely get low weight for features that have high range and high for the opposite
@cenobit0815
@cenobit0815 3 жыл бұрын
sequence length of 1 is fine if the lstm is stateful (hidden state from prev period is used as input aswell). if the lstm is statless, you need to pass the whole sequence (and zero hidden state as input). so it basically depends what kind of lstm you are training. (stateful or stateless) but lstms are still useless for price prediction, because they tend to output the last price of the input sequence. thats what i learned when playing around with lstms for stock price prediction.
@cenobit0815
@cenobit0815 3 жыл бұрын
pytorch.org/tutorials/beginner/nlp/sequence_models_tutorial.html (shows both approaches aswell)
@LazyProgrammerOfficial
@LazyProgrammerOfficial 3 жыл бұрын
"Stateful" is just another way of saying that you are passing in a sequence... the hidden state h(t) is derived from the inputs x(1), ..., x(t). If you are holding the state from past samples then there's something seriously wrong.
@cenobit0815
@cenobit0815 3 жыл бұрын
@@LazyProgrammerOfficial did you had a chance to evaluate the performance of transformes (multiheadattention) on stock price prediction? i am thinking on giving it another try :)
@emmang2010
@emmang2010 7 ай бұрын
Thank you very much. I recommend not saying that when scaling the ideas is to have values be "small". People who might take you literally will think you mean very small values (ex. 1.2x10^-20). I would also introduce stationarity at your timestamp for "Stock returns instead of ..." since this is a step towards that.
@gamingsaloon7731
@gamingsaloon7731 3 жыл бұрын
You’re right but we can use price and minmaxscaling locally to find patterns I usually apply it locally when sampling data and not on the whole data
@digitalnomad2196
@digitalnomad2196 11 ай бұрын
ya exactly, there is a local min max if you define a timeframe
@alaincheong7275
@alaincheong7275 3 жыл бұрын
This is just a promotion video, if you think carefully.
@LazyProgrammerOfficial
@LazyProgrammerOfficial 3 жыл бұрын
Interesting, please do share
@alaincheong7275
@alaincheong7275 3 жыл бұрын
@@LazyProgrammerOfficial I classified it as promotion video, as there are various contradicting information.
@LazyProgrammerOfficial
@LazyProgrammerOfficial 3 жыл бұрын
@@alaincheong7275 I welcome you to elaborate
@shahinhashemi5799
@shahinhashemi5799 2 ай бұрын
Literally true, shitting on everyone else's code with a very pretentious tone, plugging a course every other minute
@johnboyd2256
@johnboyd2256 2 ай бұрын
@@shahinhashemi5799 No he's pretty objective, and the promotion part isn't every other minute, it's a dedicated part of the video. Just like any KZbin video. Exaggeration is for those who think louder means smarter.
@hughdbrown
@hughdbrown 4 жыл бұрын
In this video you comment that using prices is wrong but using returns is correct. Does using logs of prices have the same problem? (I ask because logs of prices are commonly used in finance because they have the property that adding logs gives the return over a period of time.) Logs of prices have no min or max, so I imagine they are similarly wrong.
@LazyProgrammerOfficial
@LazyProgrammerOfficial 4 жыл бұрын
Yes, the same logic applies to log prices
@0xVantwoutMaarten
@0xVantwoutMaarten 3 жыл бұрын
It took me a while to grasp, but thank you a lot. Mistake number 5 should be all over the internet! Everybody, if you are using a training window does not mean you are using a sequence, it is about the sequence of training windows!!!!!
@M1911Original
@M1911Original 2 жыл бұрын
Holy shit I just standardized the data on one of my LSTM models and I instantly got over 10x less loss
@kartikpodugu
@kartikpodugu 3 жыл бұрын
awesome...i saw so many examples, with this mistake, but always, i felt what they are doing has some flaw. But, was unable to reason it myself. Thanks for the clarification.
@plasmaflare5217
@plasmaflare5217 11 ай бұрын
Thank you so much for explaining these concepts properly, it can be seen that you have a lot of experience in this subject. I started learning machine learning techniques for analyzing economical data but I could not figure out the best method in order to forecast stock prices.
@onceappuonatime
@onceappuonatime 4 жыл бұрын
Thanks for this video. I finally took action and bought the course on Udemy. I am broke so I usually find a way to get stuff for free so this was a big step for me. I have been trading for more than 2 years now and wanted to apply ML in ways different than what I have seen online. So, thank you for making this course!
@YaShaheed
@YaShaheed 2 жыл бұрын
How is trading going with deep learning?
@reedoken6143
@reedoken6143 Жыл бұрын
@@YaShaheed it's a grift, unfortunately.
@BoHorror
@BoHorror 6 ай бұрын
Very insightful, very true the bit about using 1 sequence not multiple.
@anshanshtiwari8898
@anshanshtiwari8898 3 жыл бұрын
Are you planning to explain more about the other mistakes?
@LazyProgrammerOfficial
@LazyProgrammerOfficial 3 жыл бұрын
Yes
@gastonvilches5851
@gastonvilches5851 2 жыл бұрын
Thank you very much for this video, I was starting to think I was worng until I saw this video. There are tons of mistakes out there, specifically on this topic.
@grabngoinfo
@grabngoinfo 2 жыл бұрын
LOVE this video! Cannot help laughing when watching the virus part, but it is so true! I am really glad that I didn’t use min max scaler in my time series tutorials. Thank you for your contribution to the machine learning community, sir!
@MansourAlAkeel
@MansourAlAkeel 3 жыл бұрын
I cannot find you other videos about other mistakes. I agree about using the return value instead of price as input. However this will result in input range between -1,1. What activation function would you use then ?
@pimpXBT
@pimpXBT 9 ай бұрын
use a moving average to continually plot a time series graph. theres indicators, theres greeks to measure total risk. returns aint normal, they are lognormal, so you'll obv have skew. Point of the video is form sequences of multiple models that create your strategy, then feed it in so it evolves over time (ML is basically used for parameter optimization, so you can get the best timeframe for a strategy, or use a timeframe to figure out the best moving avg window, rsi levels bla bla, so sequences are supposed to be multiple dimensional, not a scalar)
@pimpXBT
@pimpXBT 9 ай бұрын
../and all of these are already derived from the underlying returns and standard deviations, so they are normalized to fit the mean/variance of the underlying position/portfolio. you can just add them to your expected profit at face value, so theres your expected returns.
@LazyProgrammerOfficial
@LazyProgrammerOfficial 9 ай бұрын
Check my website for a link to all videos. Using returns would not limit the range. The range of returns is unlimited.
@doragababa3433
@doragababa3433 5 ай бұрын
@@LazyProgrammerOfficial Why the range of returns is unlimited? Doesn't it have also maximum value in your train data ?
@LazyProgrammerOfficial
@LazyProgrammerOfficial 5 ай бұрын
@@doragababa3433 Any fixed set of data would have a min and a max, that's not what is meant by "unlimited". Unlimited refers to the allowable values.
@axe863
@axe863 11 ай бұрын
Integer Differencing is excessive and may significantly erode memory content. There exists some degree of tempered fractional differencing that has minimun information destruction with "good enough" stationary
@AbhishekML
@AbhishekML 11 ай бұрын
Ha, I think you're trying to sound smart, but first differencing is standard in time series, whilst "tempered fractional differencing" shows not even 1 page of search results.
@axe863
@axe863 11 ай бұрын
@AbhishekML Overstationarizing is one of the single greatest deteriments to predictability via reduction in a time series memory content. Dr Marcos de Prado highlights the tradeoff by building models on the weakest degree of fractional differencing that rejects the null of nonstationarity (ADF statistc). The differencing-memory tradeoff is not a universality ( it doesn't hold for all processes)
@axe863
@axe863 11 ай бұрын
​@AbhishekML Financial time series (especially fragile assets) exhibit semi-long range dependency in the cmeans but especially in cvol even when one accounts for spurious fd via structural breaks. Integer Differencing destroys an excessive amount of predictability to ensure stationarity
@Timothyjackzon
@Timothyjackzon 22 сағат бұрын
Video starts at 06:36
@kyloren2093
@kyloren2093 2 жыл бұрын
Hey, thanks for the great content, i am using R, do you think it's as good as python for this kind of analysis ?
@ariisichoix5795
@ariisichoix5795 3 жыл бұрын
I really like your video. I can not agree more with all of those Video / Code example they share on youtube like it really works xD. Thank you for this video tho ! I am currently creating a real AI Trading bot using Deep RNN and I wanted to use LSTM Cells and maybe GRU Cells as well but I ended up not having good results during my training process. Hopefully your video will help me understand a little bit more why I am not able to have a better recall. (yes i am doing a classification prediction)
@Yasinzaii
@Yasinzaii 2 жыл бұрын
any luck with your project ?
@rob9207
@rob9207 2 жыл бұрын
Hi Arii, please reach out to me if you're still working on this project. Would love to talk with you.
@linknero1
@linknero1 3 жыл бұрын
Thank you, I was going to make this as a final project in a course :V thank you so much, I'll definitively go to the course
@fitybux4664
@fitybux4664 Жыл бұрын
6:25 "Some people are using a sequence length of 1... Nor is it funny or entertaining"
@SimonIslit
@SimonIslit 5 ай бұрын
Are these courses applied machine learning or advanced machine learning in depth of its working mechanism to object layer?
@anandtiwari1281
@anandtiwari1281 4 жыл бұрын
What happen if we use rolling returns instead of just returns?
@priyanshukumawat4142
@priyanshukumawat4142 4 жыл бұрын
one of the best mentor I had ever seen !!!!!! RESPECT from INDIA
@jonfe
@jonfe 9 ай бұрын
I'd discover a better way of normalize the data for stock prediction.
@125errorz
@125errorz 3 жыл бұрын
why arent priests talking about this?
@muntedme203
@muntedme203 Жыл бұрын
Stationarity with heteroskedasticity....LN rets is fine. How can you normalise with a window that extends beyond the lookback being used??? Lol
@saatviksingh
@saatviksingh 2 жыл бұрын
Ooof please post the other videos soon
@danieledicesare9447
@danieledicesare9447 3 жыл бұрын
Nice video. Keep up this series :)
@BoHorror
@BoHorror 6 ай бұрын
For Min Max scaling why not just use Zero Mean Normalization instead
@VonDutchyy
@VonDutchyy 2 жыл бұрын
Really good breakdown, nice one!
@clarencengminteck
@clarencengminteck 3 ай бұрын
after do LSTM about stock price, i agree LSTM don't work with stock prediction, because the direction of the stock totally messed out and also even have the tecnical indicator or candlesticks candle pattern does not help much too
@TheDeatheater3
@TheDeatheater3 10 ай бұрын
I am a little confused. If I am about to standardize the data then it is i.i.d data no longer sequential. In this case this case does it make sense to use LSTM at all?
@LazyProgrammerOfficial
@LazyProgrammerOfficial 9 ай бұрын
You can standardize data that is not IID. They are not related.
@MasamuneX
@MasamuneX 11 ай бұрын
tldr just use min/max on indicators on bounded quantities like the outputs of some indicators not on the price itself and dont use it on price action because you "Cap" it at the maximum value that Could easily be growing still
@mastermind2362
@mastermind2362 2 жыл бұрын
Where are the other videos? are they coming?
@atenkhu6092
@atenkhu6092 3 ай бұрын
Why should we not predict the price? Why say it's useless?
@DanielCWERTY
@DanielCWERTY 3 ай бұрын
Thats just stock price very volatile, this is cause outliers, deep learning is very sensitive about outliers, If you use price as target, the model can catch the pattern, because how volatile the price
@DanielCWERTY
@DanielCWERTY 3 ай бұрын
**can't**
@The_Mindful_Scholar
@The_Mindful_Scholar 2 жыл бұрын
I'm working on imports and exports data. I'm using Time Series Generator-LSTM . my training data prediction has r2 error = 0.99 while the testing prediction has -0.39. what parameters you suggest for better results on testing predictions?
@metehan9185
@metehan9185 11 ай бұрын
Ask chatgpt
@Pvtmovies4384
@Pvtmovies4384 7 ай бұрын
did you find any solution ? facing the same issue
@jdaniele
@jdaniele 4 жыл бұрын
50 euros? I will wait for a 9.99 offer, thanks.... :)
@spinLOL533
@spinLOL533 3 жыл бұрын
not every course goes to $9.99 lols
@jdaniele
@jdaniele 3 жыл бұрын
@@spinLOL533 that's true, as much as, not every course will sell... :)
@datascienceprofessor
@datascienceprofessor 3 жыл бұрын
@@jdaniele $9.99 course: predict stock prices with LSTMs! $50 course: pointing out all the mistakes in the $9.99 course. I rather pay more at least the instructor is honest ;)
@jdaniele
@jdaniele 3 жыл бұрын
@@datascienceprofessor Yes, maybe. So we need a $150 course pointing out "all" the mistakes of the $50 course. 😋 And we'll need a $500 course pointing out "all" the mistakes of the $150 course.... OMG😮.. 😋😋 If you go through the process, it's a asymptotic curve. Then, if we can afford it, the best is to buy a $10.000 course. hahahah😂 Will it cover all the errors? Who knows....🤔 So a $50 course could still have many errors, right? If, for example, a $9.99 course offers 85% of right information and a $50 course reaches the 92%, that 7% more (actually 8.2% more if compared to 85%), costs me 500% ($50/$10), a bit too much. So I should pay +400% to have just +8.2% more. Will it worth? Anyway, most of the discounted ($9.99 for just few days at year) courses on Udemy, are usually sold between $30 and $200. Following your reasoning, a $200 course should be better than a $50, right? So I think if we buy a $100-$200 course discounted to $9.99, it has the best value for that money, even if it is not perfect yet, for sure better than a FIXED $50 priced course! Fixed priced courses just pissed me off... sorry! 😅
@datascienceprofessor
@datascienceprofessor 3 жыл бұрын
@@jdaniele You're just reaching and making up fictitious examples. Lazy is well known for having actually studied this type of material and applying it day to day. The others are obviously just marketers trying to capitalize on trends like ML and crypto. If you can't tell the difference, then you're probably not the target audience for this kind of course.
@russnagel1
@russnagel1 3 жыл бұрын
Why is this episode 16? Where is episode 15? Is this part of your paid for course?
@LazyProgrammerOfficial
@LazyProgrammerOfficial 3 жыл бұрын
These are not part of a course, these are part of KZbin. You can click on my KZbin channel to see all the videos I've uploaded as usual on KZbin.
@51nibbler
@51nibbler 2 жыл бұрын
is not importent to keep it in same scale. but i made not a prediction of the next N steps of price. i made only buy sell or wait in CFD forex :) then when you understand you can normalize the input data i have 25200 ticks as input data AUDUSD. but the normalization i m not use a formel from statistic or internet i have my own formel to calculate normalize input data :) yes you have right. not copie a code. understand how it work and write it self. and test it. and test it.. and test it.. and when your later version are better you can made more version^^ when not start at begin and learn to understand how Q-learning work^^ greeze from switzerland and yes my englisch is bullshit xD i made it since 1 year as a hobby.. first version was on 23% off all trades are win trades and atm 32% of all trades are win trades and when i had 34% the ai made win with 50pips TP 20pips SL :P
@51nibbler
@51nibbler 2 жыл бұрын
and NEVER EVER NEVER sue the SAME input DATA for 2 times!! you not want that your KI only can trade only YOUR INPUT data look YT videos 99.9999% only train with the same INPUT DATA so long that the KI the input data KNOWS xD thats bulshit i use test data from AUDUSD different times USDCAD EURUSD AUDCAD etc etc etc 4 years data and more... in 1 train step to see is this version a version with potenzial or crap but you NEVER know how LONG U must TRAIN to KNOW that it work YOU NEVER KNOW :P
@vinniehuish3987
@vinniehuish3987 7 ай бұрын
@@51nibblerWtf are you saying you Indian.
@linknero1
@linknero1 3 жыл бұрын
I have a question: is it possible to use that idea to find patterns in hours instead of days? I mean, there are some observable patterns, like: "some stocks gain or lose right before they close and begin the day up (and lose) or low and increase over the day". Is it possible?
@aravindkolli
@aravindkolli 11 ай бұрын
Is it same with lag of prices as inputs?
@LazyProgrammerOfficial
@LazyProgrammerOfficial 10 ай бұрын
This video is about lagged prices as inputs!
@leonloncaric7715
@leonloncaric7715 13 күн бұрын
i love this video.🎉❤😮
@barrard
@barrard 7 ай бұрын
Discount?
@LazyProgrammerOfficial
@LazyProgrammerOfficial 7 ай бұрын
Can be found at my website!
@kilocesar
@kilocesar 9 ай бұрын
I'm creating my own library with GPT now, I don't have to rely looking for scrapes of others coders.
@LazyProgrammerOfficial
@LazyProgrammerOfficial 9 ай бұрын
Unbeknownst to you, GPTs are trained using Github code and therefore make the exact same mistake. I covered examples in one of my courses.
@kilocesar
@kilocesar 9 ай бұрын
I use it to implement the initial structure to same time, but I'll know what you mean.@@LazyProgrammerOfficial
@MarvinEckhardt
@MarvinEckhardt 2 жыл бұрын
lstm is old. use transformers
@calendr13
@calendr13 2 жыл бұрын
I am in the sector, The only useful video about stock price prediction !
@dzel774
@dzel774 3 жыл бұрын
I just discovered your channel and I’m interested in the VIP course.
@LazyProgrammerOfficial
@LazyProgrammerOfficial 3 жыл бұрын
Welcome! You can find links to the VIP versions of my courses via my website, lazyprogrammer.me
@dzel774
@dzel774 3 жыл бұрын
@@LazyProgrammerOfficial thank you
@spinLOL533
@spinLOL533 3 жыл бұрын
6:05 lmao
@kabokbl2412
@kabokbl2412 2 жыл бұрын
hmu when he makes the course free, i dont have money to buy it
@andrey5197
@andrey5197 2 ай бұрын
Meme is speaking about LSTM without understanding the core idea of LSTM 😂
@LazyProgrammerOfficial
@LazyProgrammerOfficial 2 ай бұрын
If you think there's a mistake here, can you state it?
@andrey5197
@andrey5197 2 ай бұрын
@@LazyProgrammerOfficial LSTM works with sequences.
@LazyProgrammerOfficial
@LazyProgrammerOfficial 2 ай бұрын
@@andrey5197 The video doesn't state that LSTM doesn't work with sequences. Did you not understand the video?
@andrey5197
@andrey5197 2 ай бұрын
​@@LazyProgrammerOfficial2:40
@LazyProgrammerOfficial
@LazyProgrammerOfficial 2 ай бұрын
@@andrey5197 Not sure what you're implying - you didn't understand what was being said at 2:40?
@dineshkrishnasamy1628
@dineshkrishnasamy1628 2 жыл бұрын
Hi. How to get VIP materials please
@petemoss3160
@petemoss3160 Жыл бұрын
heh heh heh
@Rvl734
@Rvl734 3 жыл бұрын
Sir i need a project of stock price prediction lstm model (back propagation algorithm) and maa website or web app or using streamlit i will pay you reply to this comment
Long Short-Term Memory (LSTM), Clearly Explained
20:45
StatQuest with Josh Starmer
Рет қаралды 606 М.
LSTM Time Series Forecasting Tutorial in Python
29:53
Greg Hogg
Рет қаралды 222 М.
Симбу закрыли дома?! 🔒 #симба #симбочка #арти
00:41
Симбочка Пимпочка
Рет қаралды 5 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
Predicting Stock Prices and Making $$$ Using the ARMA Model
9:57
Reinforcement Learning Course - Full Machine Learning Tutorial
3:55:27
freeCodeCamp.org
Рет қаралды 913 М.
Financial Machine Learning - A Practitioner’s Perspective by Dr. Ernest Chan
57:32
I Day Traded $1000 of Stocks using the LSTM Model
16:07
ritvikmath
Рет қаралды 16 М.
Time Series Forecasting with XGBoost - Advanced Methods
22:02
Rob Mulla
Рет қаралды 130 М.
Симбу закрыли дома?! 🔒 #симба #симбочка #арти
00:41
Симбочка Пимпочка
Рет қаралды 5 МЛН