Stock Price Prediction Using Python & Machine Learning

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ส.ค. 2024

ความคิดเห็น • 1.3K

  • @snivesz32
    @snivesz32 4 ปีที่แล้ว +436

    The flaw nobody seems to have realized is that it’s predicting 1 day in the future GIVEN the last 60 days of actual values. So each prediction on the graph is actually using the validation data from yesterday + the NN prediction for today. Anyone can now see why it tracks the chart so accurately. I could get the same chart with a random number generator.
    Caveat emptor.

    • @diegotrazzi
      @diegotrazzi 4 ปีที่แล้ว +37

      I see your point: if you seeded any number within 1 standard deviation form the previous day to predict today's price, then zooming out to a large timeframe you could get a very similar chart. You brought up a good point and seem to be knowledgeable on this topic, so what would you do to implement a better forecast model ? Suggestions are appreciated, thanks!

    • @weimondo
      @weimondo 4 ปีที่แล้ว +35

      @@diegotrazzi It's not possible. Assuming a sufficiently efficient market, if it were possible to forecast asset prices then people would take advantage and trade on such information. Price actions would then disappear.

    • @RobertvonSarbacher
      @RobertvonSarbacher 4 ปีที่แล้ว +34

      @@weimondo NOT TRUE that's a total fallacy - the whole insane and inane premise that you cannot predict the future to find for example - a cycle in the market that no one knows about it and make a profit off of it b/c everyone will eventually learn it and use it thus incorporating into the market therefore it is not longer a predictor - this whole premise is so absurb as to make even the term "laughing stock" blush - all you have to do is NOT tell someone else what you discovered and the prediction holds - take for example the Scandavian Finance professor in the 90s that discovered an 80% accurate super cycles that was so freakishly exact like to 1 or 2 day out of every 2 months ish in finding the total and absolute highs and lows of almost everything that occured every 2-3 months - but being a brainwashed bonehead - tells the whole world about it - it was then put onto every Media in the world like Nightly Business Report - the euro continents finance channel and all the finance channels in the USA - it stilll took 2 MONTHS to have it incorporated by rest of the world but in mean time predicted every major and sometimes even minor turns in the USA stockmarket (never mind every other stockmarket index on the planet ) - now despite the fact that that is MORE than enough to make a few billion dollars and retire - keep in mind had he not been a brainwashed bonehead and had he kept this info secret it would never have been known and never incorporated into the stockmarket at all.... is this not common sense - FEEL FREE TO NOT REPLY BACK GEEZZZZ

    • @dweh
      @dweh 4 ปีที่แล้ว +6

      @Diego Trazzi There is the question that everyone in trading market are looking for! Who knows?

    • @drcesarvarela
      @drcesarvarela 4 ปีที่แล้ว +7

      @@dweh I guess CITADEL LLC knows about it pretty well.

  • @rajeshdua558
    @rajeshdua558 4 ปีที่แล้ว +48

    I have seen 1000+ videos, read 1000+ articles on the internet. The best of the videos I have ever seen on machine learning.

    • @sahilsharma-gm1ed
      @sahilsharma-gm1ed 4 ปีที่แล้ว +3

      Rajesh Dua chutiye
      .

    • @SebastianWaisgold
      @SebastianWaisgold 8 หลายเดือนก่อน

      True

    • @AnonymUwo
      @AnonymUwo 4 หลายเดือนก่อน

      Just look for Andrew Ng's courses. I'm sure it will change your mind

    • @inasissa8077
      @inasissa8077 4 หลายเดือนก่อน

      Thank you for your response i will watch it after watching alot of video

  • @alexroseland9286
    @alexroseland9286 4 ปีที่แล้ว +268

    I recreated this exact model and then checked to see how often the simple up/down movement of the price was correct (never mind the actual change amount), it couldn't reliably get better than 50% so it's basically the same thing as randomly guessing a slight up or down movement. So this was a cute demonstration of the concept but you'll definitely lose your ass if you tried to trade on anything like this haha. You need a vastly more complex model to start consistently getting higher than 50% and even then if there are large market corrections, they will definitely break your model. So Something like this might give you some minor assistance in day trading but you wont get rich one it. But anyways, we certainly appreciate the explanation on how general LSTM model functions

    • @martinholmes3305
      @martinholmes3305 3 ปีที่แล้ว +7

      I am glad to see someone tried it while using only past data. The conclusion you make is what I would concur with just by simple reasoning. There should be a need for another factor at least to hope to get some sort of accuracy. Unless there is a repeated pattern to be found somewhere due to a factor we are unaware of. Like patterns in roulette due to flaws making the results not quite random. Something that has surely been caught onto, and is probably now verified for at casinos.

    • @ishanawasthi1975
      @ishanawasthi1975 2 ปีที่แล้ว +22

      Actually this model will accurately tell you the range of values that the stock has high probability of trading in. Example if model prediction is 180 with rmse of 5 then there is 65% chance that it will close between 175 - 185 range, and there is 95% chance that it will close between 170 - 190 range given that stock returns are randomly distributed and it follows standard normal distribution. If someone knows the range maybe they can wait for the stock to hit either high or low before taking trade or they can deploy option strategies based on the information they got from the model.

    • @themoneymaker03
      @themoneymaker03 2 ปีที่แล้ว +1

      @@ishanawasthi1975 good point!!! 👍

    • @Sachin-ww1ns
      @Sachin-ww1ns 2 ปีที่แล้ว

      How can use multiple data as a input to classify which stock to pick ? from high to low. let's say I input 10 datasets at once & it classifies top 3. (just for project purpose)

    • @bloglifenguyen3028
      @bloglifenguyen3028 2 ปีที่แล้ว +5

      His model is literally overfitting with the absurd accuracy

  • @yx2023
    @yx2023 4 ปีที่แล้ว +4

    For anyone criticising the effectiveness of this algorithm...you are missing the point. This is a very good FREE tutorial on applying LSTM & RNN to real world datasets using python, for learning purposes only. It's a standard and basic learning topic for Neural Networks. To criticise this would be same as saying Man City should win UCL every year based on their FIFA20 stats...

  • @touriafransform6280
    @touriafransform6280 4 ปีที่แล้ว +31

    40:03 It is meaningless and misleading to plot predictions (especially zoomed out) unless you do out-of-sample forecasting. Many people are just obsessed with plotting forecast curves and comparing them with actual curves. It has got to stop! You can get a better fit by predicting the next value to be the current value. Out-of-sample forecasting is when the model is forced to predict N steps successively while not being provided with the true values of the previous time steps. Over time, errors would accumulate and the prediction curve would sway away from the actual curve. Only if you are doing out-of-sample forecasting, it makes sense to plot.

    • @leonidasat
      @leonidasat 3 ปีที่แล้ว

      Hi! I agree with you. I'm new to this so I'd like to know if you see a way to deal with this problem so you can better predict the time series. Thanks!

    • @Otvazhnii
      @Otvazhnii 3 ปีที่แล้ว

      Why predicting several steps? Why not predicting simply if it goes up or down in the next several steps? Is it not easier for a model to predict that?

    • @amandinelevecq6664
      @amandinelevecq6664 2 ปีที่แล้ว

      @@Otvazhnii Maybe not easier to get the acurate direction, but a lot more useful 😄

  • @QuranKarreem
    @QuranKarreem ปีที่แล้ว +5

    Great ,but there is one small thing you missed which may introduce bias into your model. To avoid leakage from the test set into the training set, it is important to split the data before applying any preprocessing steps. This is because the preprocessing steps can introduce information from the test set into the training set, leading to overly optimistic performance estimates and poor generalization performance on unseen data.
    so you have to split the data before scaling

    • @neto_x
      @neto_x ปีที่แล้ว +1

      I noticed this too...

    • @paultvshow
      @paultvshow 6 หลายเดือนก่อน

      Exactly what I thought. I have noticed many TH-cam’s make some mistakes here and there too. I think they should be more professional to rely on.

  • @natih8585
    @natih8585 4 ปีที่แล้ว +3

    I think this model is good for practice but not for real use. 1st issue is the scaling, you should scale based on the training set, not the full dataset, 2nd issue is the test dataset, the prediction works if you know the previous 60 days of the data for all the testing set. It would be good to see how is the performance of predicting next days (1+ days) just using a single vector of previous 60 days.

  • @LovingLego
    @LovingLego 2 ปีที่แล้ว +1

    This is the best video of LSTM I saw. I don't understand why do some people dislike this video ?

  • @mikethecoder341
    @mikethecoder341 3 ปีที่แล้ว +5

    one change that can be done here is increasing epochs if your ram can handle , because that would increase accuracy. Great video!

    • @SahilKhan-td6rv
      @SahilKhan-td6rv 3 ปีที่แล้ว +1

      Bro tell me what is the best value for epoch and batch size

    • @zalakborad617
      @zalakborad617 6 หลายเดือนก่อน

      there is no best value found yet on planet earth, you have to try different combinations.
      @@SahilKhan-td6rv

  • @robertjulesyoung9994
    @robertjulesyoung9994 2 ปีที่แล้ว +4

    I think the markets are moving solely based on the psychology of the investors. therefore, technical analysis is the only valid approach. for example, it does not really matter how good a company is doing, if investors are paying attention, understanding their future. AI is making things a lot easier, by looking into investors' behavior. thanks for the great insight.

  • @oy_oy
    @oy_oy 3 ปีที่แล้ว +2

    The script here is in the right direction, naturally it needs two key columns: Add high/low/volume variables, since it represents people's sentiment and join a new dataset from other currencies. I would say low performance coins with the highest ones is a good combination.

  • @WilliamReynolds887
    @WilliamReynolds887 2 ปีที่แล้ว +13

    As the economic crisis keep rising one needs to have different streams of income, as well secure a profitable investment for the future.detailed diversified investment portfolio in the financial markets is needed to survive! Wondering if investors here are familiar with Pamela Kay weaver trading strategies.?

    • @meredithpoor1042
      @meredithpoor1042 2 ปีที่แล้ว

      When it comes to the world of investing, most people don't know where to start. Fortunately, great investors of the past and present can provide us with guidance

    • @meredithpoor1042
      @meredithpoor1042 2 ปีที่แล้ว

      With expert pamela weaver everything is possible in crypto trading, i traded $7600 for a start, i am proud to say i made it today

    • @Marine40
      @Marine40 2 ปีที่แล้ว

      She is one of the best signal providers and I have made quite a lot of money without losing money even in declining market.

    • @sirmoritzo.schulte5392
      @sirmoritzo.schulte5392 2 ปีที่แล้ว

      I am a living beneficiary of her trading scheme and I made an enormous profit with her last year before I started trading full-time all by myself.

    • @anthonysanchez9094
      @anthonysanchez9094 2 ปีที่แล้ว

      I have heard a lot about Investments, with Mrs pamela how good she is and how she has helped People. Please how safe are her profits?

  • @mariahhayes5089
    @mariahhayes5089 11 หลายเดือนก่อน +116

    Absolutely amazing video, I have finally realised that as a beginner in the financial investment market, you can achieve close to nothing yourself because you still have a lot to learn. Trading with a professional broker is more profitable and my advice for beginners is to always take advantage of that.

    • @raymondbarnes5264
      @raymondbarnes5264 11 หลายเดือนก่อน

      Instead of timing the market, you should try to diversify your portfolio in order to get a dollar-cost average when it’s time to retire. Keep in mind that you don't need a ton of money to invest. Investing in small amounts can build long-term wealth too!

    • @greenquake11931
      @greenquake11931 11 หลายเดือนก่อน

      I'm an amateur making terrible picks and I really need assistance.

    • @stellamoore720
      @stellamoore720 11 หลายเดือนก่อน

      Trading is Profitable with the help of a seasoned broker managing your trading account .

    • @mariahhayes5089
      @mariahhayes5089 11 หลายเดือนก่อน

      @@greenquake11931 'BRIDGET MARY TUROW"".

    • @greenquake11931
      @greenquake11931 11 หลายเดือนก่อน

      @@mariahhayes5089 How can i reach her?.

  • @javierhugo5412
    @javierhugo5412 2 ปีที่แล้ว +33

    Reading about people grabbing multi-figures monthly as income in investments even in this crazy days in the market,any pointers on how to make substantial progress in earnings?would be appreciated

    • @sandraken5250
      @sandraken5250 2 ปีที่แล้ว +2

      You have to have an idea on what you wanna invest in carefully before going in

    • @georgewilson2434
      @georgewilson2434 2 ปีที่แล้ว

      You make it seem unreal to make up to that as a passive income annually,when it’s clearly possible😁😁Albertmathe has really made me rich through his strategies💰💯

    • @georgewilson2434
      @georgewilson2434 2 ปีที่แล้ว

      Access him through the tele gram page

    • @georgewilson2434
      @georgewilson2434 2 ปีที่แล้ว

      Albertmathe is the name

    • @albertpitts417
      @albertpitts417 2 ปีที่แล้ว

      This man right here,I trade with him he’s inventive and the P.O.T are no jokes, I won’t look awestricken u made mention of him

  • @AtillaYurtseven
    @AtillaYurtseven 2 ปีที่แล้ว +1

    Well don't get too excited guys. Because every model predicts a price very close to the closing price. If you zoom the chart, you can see that yellow prediction is next to red ones. So this is not going to help you to make money. It's almost similar to shifting price one day to the future. Stop trying to predict. YOU CANNOT FORECAST THE FUTURE PRICES!

  • @icutoo2699
    @icutoo2699 3 ปีที่แล้ว +11

    The video was great, saved me a lot of time trying to figure it out myself. Also learn how to use the python syntax. On a side note, back of the envelope calculations. dec 17,19 aapl = 70.1, dec 17, 09 appl = 6.85. (70.1-6.85)/6.85 = 9.233 or 923% return over 10 years, 923%/10yr = 9.23%/year, 9.23%/365 days/yr = 0.0253%/day. If we use the previous day closing as an estimate plus the average daily change then, 70.1*(1.000253) = 70.118, accounting for the 1 to 4 stock split the price on the 18th is estimated at 70.1177 x 4 = 280.47, act close 279.74, vs AI 263.66. Would have been interesting to see which one would be better est, previous Close +% or AI, with the standard error.

  • @merrymouse2008
    @merrymouse2008 ปีที่แล้ว +10

    Wonderful tutorial! Thank you very much for making it. I am making a project to impress the interviewer at the potential working place. I already did a prediction model using ML and Python but it was a simple Linear regression model. Thank you for your work. My model works perfectly. The only thing I can't figure out is how to trained it connected to timestamp. But otherwise it works. My tiny laptop CPU almost melted counting 38 000 rows of data XD

    • @Gamermiddleclass
      @Gamermiddleclass ปีที่แล้ว

      I am trying to make the same including the optimal time to buy and sell the stock . Give me tips if you have any .

  • @nelsondesantijunior1527
    @nelsondesantijunior1527 4 ปีที่แล้ว +58

    Thank you for the video. Could you demonstrate how to use lstm with two input data, for example close price and volume?

  • @tomasemilio
    @tomasemilio 4 ปีที่แล้ว +5

    I have 2 issues with this: 1. can't use testing data for the scaler. 2. I would predict a sequence instead of tomorrow's price. these plots are a bit deceiving because they are so close to each other but it is bc you are always using yesterday's close. It would be interesting to actually predict a sequence into the future.

    • @sifisojuniorhadebe476
      @sifisojuniorhadebe476 ปีที่แล้ว

      Yea that's true, I used a similar model projecting EURUSD but the spread between actual and projected averaged 100pips which is a nono

  • @MrBobtwang
    @MrBobtwang 4 ปีที่แล้ว +3

    I wouldn't put much store in the model created to be honest for reasons others have raised about scaling but as a 'get you going' video into the perilous world of trading using ML then it's an honest attempt - well done.

    • @tanmaysharma2742
      @tanmaysharma2742 3 ปีที่แล้ว

      Hey you seem like an expert . Can you please guide me as I have been really wanting to get into trading and finance using machine learning. I would really appreciate it if you could give me resources that could get me industry ready to create complex algorithms that can help me out.

  • @ekinrota1638
    @ekinrota1638 3 ปีที่แล้ว +43

    Just saw the video, thanks for the effort! One question though, isn't it leaking data when you do the scaling before splitting data into train/test sets?

    • @robertweber475
      @robertweber475 2 ปีที่แล้ว

      you have to scale train and test data with the same parameters.. otherwise you distort results

    • @ekinrota1638
      @ekinrota1638 2 ปีที่แล้ว +3

      @@robertweber475 yes but you can do that with scaling on train data first and using the same trained scaler on the test data

    • @robertweber475
      @robertweber475 2 ปีที่แล้ว

      @@ekinrota1638 yes, that would be possible

    • @peterjamieson4082
      @peterjamieson4082 2 ปีที่แล้ว +1

      @Jeremy Tran Jeremy is correct. The presentation is wrong and needs to be edited.

  • @samha1513
    @samha1513 4 ปีที่แล้ว +20

    *Good for learning purposes only*

  • @sabashioyaki6227
    @sabashioyaki6227 ปีที่แล้ว +1

    The comment at the end is priceless, "...off by a little bit." Go back and look at the price action from the end of August 2019 until about mid Jan 2020 and you'll see why this prediction of a 6% drop in the closing price is surprising. It would be nice if there had been some explanation of why the prediction was so far off and how to improve the result.

  • @martinholmes3305
    @martinholmes3305 3 ปีที่แล้ว +4

    Love the video, very intriguing. One really feels like repeating this program design with a pre-edited set of data to verify the accuracy of the hypothesis created by the viewing of it. It is like a psychological experiment, social experiment, statistical experiment, computer science lesson all rolled into one. Hello World of Python.

    • @krizh289
      @krizh289 2 ปีที่แล้ว

      Would be fairly easy to verify the accuracy, you should do it

  • @arupbiswas3487
    @arupbiswas3487 4 ปีที่แล้ว +3

    model.add(Dense(25))
    model.add(Dense(1))
    This has resulted into RMSE of 0.38 , adding one more neural trace model.add(Dense(25))
    may be the reason

    • @jeyasuriyam5185
      @jeyasuriyam5185 3 ปีที่แล้ว

      why we take range as 60. Can you please explain

    • @kshitijsharma24
      @kshitijsharma24 3 ปีที่แล้ว

      How to fetch prices of Indian stocks

  • @npomfret
    @npomfret ปีที่แล้ว +6

    It would be interesting to see how this compares with a basic strategy, like just predicting todays close will be the same as yesterdays close. I imagine the LSTM doesn't perform as well

  • @arcsaber1127
    @arcsaber1127 2 ปีที่แล้ว +2

    This video helped me a lot. I was struggling with the inputs to the Conv. Turns out it just required simple 3d inputs to fit and another 3d array input to predict

  • @bobjazz2000
    @bobjazz2000 4 ปีที่แล้ว +5

    What you want to predict is whether tomorrow’s price is higher or lower than today’s price.

  • @christospapageorgiou9560
    @christospapageorgiou9560 4 ปีที่แล้ว +7

    Very good job! If you combine this with technical indicator values it will give you very good predictions. And probably split it to different timeframes. Also, I noticed that if you retrain the model until you get better results and then try to predict the prices you got accuracy near to 99%. So, with a combination of technical indicators and by retraining the neural network until it is more accurate you are getting great results! Excellent job! Great Video.

    • @ComputerSciencecompsci112358
      @ComputerSciencecompsci112358  4 ปีที่แล้ว +1

      Thank you Christos !

    • @shogun9409
      @shogun9409 10 หลายเดือนก่อน +1

      Can i get a video on how to combine the technical indicators to this pls? I am thinking of doing this as my final year project

  • @wmichaux6277
    @wmichaux6277 4 ปีที่แล้ว +33

    Nice job. However, there is a small error in your equation for RMSE. You need to take the mean of the squared residuals rather than the square of the mean of the residuals.

    • @evandieterich8129
      @evandieterich8129 4 ปีที่แล้ว

      w michaux can I send you some code to take a look at and maybe give me some pointers on what i can do better. my code runs im just not getting the results i intended and do not know where or why im stuck

    • @amidatongassassin
      @amidatongassassin 4 ปีที่แล้ว +11

      If I'm not mistaken it is rmse = np.sqrt( np.mean( (predictions - y_test)**2 ))

    • @ashokwadel2502
      @ashokwadel2502 ปีที่แล้ว

      @@amidatongassassin nope getting the same error its giving me nan output

  • @WillsJazzLoft
    @WillsJazzLoft หลายเดือนก่อน +1

    When you undertake this project in Python notebook as the presenter has done Gemini AI will complete the code for you by suggesting the lines of code. To accept what is suggested, just press the tab key on your keyboard. Through running the code can and getting an explanation from the Gemini AI regarding the errors, I determined that the API had changed.

  • @WillsJazzLoft
    @WillsJazzLoft หลายเดือนก่อน +1

    Okay here's the deal,.... The Yahoo finance API has likely changed since this video was first published. For all of those introductory lines of code importing all those different packages you only need a single line now as follows: import yfinance as yf

  • @Gatolailo
    @Gatolailo 4 ปีที่แล้ว +11

    45:43 how you predict 5 o 10 consecutive days... not just 1?

  • @shaw7598
    @shaw7598 4 ปีที่แล้ว +216

    If you just prediction every day's close price as previous day's close price, you get a better model than this

    • @saravanvel466
      @saravanvel466 4 ปีที่แล้ว +14

      Ur brilliant u will sure succeed in share market like warrent Buffett

    • @RoboticusMusic
      @RoboticusMusic 4 ปีที่แล้ว +3

      What do you mean?

    • @shaw7598
      @shaw7598 4 ปีที่แล้ว +37

      @@RoboticusMusic This RNN yields an error of ~16 dollars. If you always predict tomorrow's closing price as yesterday's closing price from 2001 to 2020. You get 0.71 dollar mean absolute error. abs(df.close.diff(1)).mean() == 0.7417740650899958

    • @RoboticusMusic
      @RoboticusMusic 4 ปีที่แล้ว +6

      @@shaw7598 If yesterday's close is $100 and today's close is $101, you're saying predicting that tomorrows close is $100 is accurate on average of how many ticks?

    • @shaw7598
      @shaw7598 4 ปีที่แล้ว +3

      @@RoboticusMusic Nobody is talking about tick data

  • @sergiysergiy8875
    @sergiysergiy8875 ปีที่แล้ว +2

    As you say, there was leakage in the model. That's why it showed such good results.

  • @aashishkandel6112
    @aashishkandel6112 3 หลายเดือนก่อน

    There are so much remaining to learn, but this was some intresting stuff. I learned about LSTM(Long Short Term Memory), taking the data from web directly, preprocessing the data,training the data and also visualizing the data.

  • @KennTollens
    @KennTollens 3 ปีที่แล้ว +3

    11:07 Lieutenant commander Data, nice rough estimated guess lol ! Thanks for the video, very useful.

    • @Bokgat
      @Bokgat 3 ปีที่แล้ว

      But the shape of the predicted graph was uncannily accurate no? Surely something there? Did you watch the entire thing? Just asking and thanks for your post here. Cheers

  • @mohamednedal
    @mohamednedal 4 ปีที่แล้ว +6

    Thanks for the great tutorial! A couple of questions please.
    To establish a Multivariate Multi-Step LSTM Models - Multiple Input Multi-Step Output:
    1. How can I modify this code to take, for instance, 3 inputs to forecast a different single output that depends on those 3 inputs?
    2. How can I forecast multiple timesteps in the future without knowing the new inputs (because they're in the future)?

    • @anujsrivastava5316
      @anujsrivastava5316 4 ปีที่แล้ว

      Same doubt, anyone please share any resources about it?

    • @mvst4u493
      @mvst4u493 2 ปีที่แล้ว

      @@anujsrivastava5316 If you find solution, Kindly mention

    • @folashadeolaitan6222
      @folashadeolaitan6222 2 ปีที่แล้ว

      Hi guys, Did you find a way to do the multivariate?

  • @aryanchauhan8711
    @aryanchauhan8711 3 ปีที่แล้ว +1

    Seriously I believe it is impossible to forecast prices so that results are profitable. Still this is a very nice educational video.

  • @PrabhuCS
    @PrabhuCS 3 ปีที่แล้ว +2

    Ah! Beautifully expalined. May you reach 10 Million subscribers. Your classes are gold :)

  • @kolavithonduraski5031
    @kolavithonduraski5031 4 ปีที่แล้ว +13

    i dont understand anything... but the voice is calming down... and it sounds interesting 😆👍 Thanks for the video. Maybe i will understand it in 2 Years or so 🤓

    • @delectomorfo
      @delectomorfo 5 หลายเดือนก่อน

      Any luck?

    • @kolavithonduraski5031
      @kolavithonduraski5031 5 หลายเดือนก่อน

      i started to research python+tensorflow, but i sadly didnt have time to stick to it. (i am just a hobby programmer)...
      BUT i appreciate you asking❗😁

  • @atyabtosif584
    @atyabtosif584 ปีที่แล้ว +7

    Really nice tutorial, however if anyone could tell me why did we keep the range from 60 specifically for the xtrain and ytrain timeseries datasets, it would be a huge help

  • @nilskohring
    @nilskohring 4 ปีที่แล้ว +2

    It's crucial to square before taking the average when calculating the RMSE. Otherwise, any unbiased model should get a really low value with just enough data...

    • @ComputerSciencecompsci112358
      @ComputerSciencecompsci112358  4 ปีที่แล้ว +1

      I made a mistake on the rmse calculation but have the correct code for it in the description.

  • @ItisAbuTDMM
    @ItisAbuTDMM 2 ปีที่แล้ว +2

    Really enjoyed learning the LSTM application for stock price prediction. I noticed that the prediction has overfitting and this is probably because you have not included Dropout in your model. Thanks

  • @kyucho1018
    @kyucho1018 4 ปีที่แล้ว +140

    Data Science 101 : Never scale your data set with a test or validation set.
    You can't scale the entire dataset which introduces significant leakage to your model.

    • @daspittin9954
      @daspittin9954 4 ปีที่แล้ว +10

      can you elaborate on what you mean, please?

    • @ianmoore957
      @ianmoore957 4 ปีที่แล้ว +21

      ​@@daspittin9954 Looking through the code, I see that he did a fit_transform on the entire dataset, then used that same scaler model to transform the test set back; he should have only used the training set when he fit the original scaler model; not both training and test, its akin to someone writing an exam, and giving them hints as to what the answers are (when estimating the predictions), but not providing the actual answers

    • @surengrigorian7888
      @surengrigorian7888 4 ปีที่แล้ว +2

      How would one correct this error, in terms of the code?

    • @ianmoore957
      @ianmoore957 4 ปีที่แล้ว +28

      @@surengrigorian7888
      This is the general approach, which you'll have to implement after the step where he implemented the lag structure
      > scaler.fit(X_train) # scaler model fit to training set only
      > X_train_scaled= scaler.transform(X_train)
      > # some code ....
      > X_test_scaled = scaler.transform(X_test)

    • @lucast2212
      @lucast2212 4 ปีที่แล้ว +2

      I see how this is an unsound practice, but scaling the input data should only make the training a bit more simple. In the end you should get the same result, up to a factor for the weights in the first layer. Plus the difference in scaling is rather low, so it is really not a big deal here.

  • @mrcc9589
    @mrcc9589 4 ปีที่แล้ว +5

    Foremost.. great tutorial! I really enjoyed the practical example for the purpose of learning how to use LSTM in python. Regarding the results of the neural network: It is obvious that the predictions are chasing the trend, similarly how a simple moving average would do. But a good starting point for exploring the possibilities of a RNN.

    • @omkarmasal2148
      @omkarmasal2148 4 ปีที่แล้ว

      What if I want to predict the for the date that is not in my train dataset i.e I would use my whole dataset as training dataset and would create a module 2 predict the future price?

  • @fredyhazard6412
    @fredyhazard6412 6 หลายเดือนก่อน +2

    I do everything the same and I got that
    df = web.DataReader('AAPL', data_source='yahoo', start='2012-01-01', end='2024-02-16')
    df
    TypeError: string indices must be integers, just in the begginer
    😭 help please

    • @Suheng-dn9cd
      @Suheng-dn9cd 5 หลายเดือนก่อน

      Same error here, waiting for answer

    • @Suheng-dn9cd
      @Suheng-dn9cd 5 หลายเดือนก่อน +4

      get an answer from the comment below, hope it helps. "import yfinance as yf and change the line of code to df = yf.download('AAPL', start='2012-01-01', end=end='2019-12-17'). It seems like yahoo changed their api and these changes broke compatibility with pandas datareader" , and thank you @lucaartz

    • @fredyhazard6412
      @fredyhazard6412 5 หลายเดือนก่อน

      @@Suheng-dn9cd thank you very much

    • @abhijitbhandary4940
      @abhijitbhandary4940 5 หลายเดือนก่อน +2

      from datetime import datetime
      import yfinance as yf
      yf.pdr_override()
      symbol = "AAPL"
      today = pd.to_datetime("today") # Ensures today's date
      start_date = datetime(2012,1,1)
      end_date = today
      # Retrieve historical data
      df = pdr.get_data_yahoo(symbol, start=start_date, end=end_date)
      df

    • @twcphd
      @twcphd 4 หลายเดือนก่อน

      ​@@Suheng-dn9cd Thank you very much

  • @Donald_Putin48
    @Donald_Putin48 4 ปีที่แล้ว +2

    So, as a piece of general information to everyone, the process is alright but the model is not so powerful. Try to tweak this model and you would get a very good result.

  • @lindajoebert9406
    @lindajoebert9406 2 ปีที่แล้ว +31

    Excellent Cryptonaire course! I now have a core understanding of trading & investing in Cryptocurrencies. Thank you Mr Paulson Dmitriev. He explain it all so in depth, even for the advanced users. So no matter your experience there’s always something you can learn!

    • @jaybarton457
      @jaybarton457 2 ปีที่แล้ว

      What's his contact details ?

  • @Ronybech
    @Ronybech 3 ปีที่แล้ว +6

    Using the previous value "yesterday" in the forecast, it is likely that the forecast will be more accurate. You need to predict for a more impressive period to assess the strength of the algorithm.

    • @finaldaylight3804
      @finaldaylight3804 2 ปีที่แล้ว

      but what if i just want tomorrows prediction, shouldn't i be satisfied with that?

  • @goodyonsen77
    @goodyonsen77 2 ปีที่แล้ว +2

    This isn't for coin prediction. It's for "stocks" (AAPL in particular). Stocks historically attract investors "based on their past price performances", if not on their specific ratios. These past price data is vulnerable to very little or no manipulation due to strict regulations by the governments. So there's no point in predicting coin prices when there's NO REGULATION and zillions of tons of manipulation going on thru the so-called pump channels, etc. Stay away from coins unless you're part of a community that do those pumps because it's merely a gambling.

  • @subhamroul6099
    @subhamroul6099 2 ปีที่แล้ว +2

    the code df is not running

  • @arioncheng3024
    @arioncheng3024 2 ปีที่แล้ว +3

    df = web.DataReader('AAPL',data_source='yahoo',start='2012-01-01',end='2019-12-17'), this command seemed not work any more!

    • @oscura15
      @oscura15 ปีที่แล้ว +1

      do you know what else i can write here?

    • @sibusisoharvey2652
      @sibusisoharvey2652 5 หลายเดือนก่อน

      @@oscura15 there's similar question above yours with a different answer you can check that out, but i used data_source = 'stooq' and it works fine

    • @sibusisoharvey2652
      @sibusisoharvey2652 5 หลายเดือนก่อน

      remember to import yfinance as yf

  • @Abdolahy
    @Abdolahy 3 ปีที่แล้ว +4

    That was a great debut for me in this field, thank you so much for sharing this kind of stuff with us. :)

  • @malepatirahul7339
    @malepatirahul7339 3 ปีที่แล้ว +1

    I think I have seen every tutorial on TH-cam for predicting the extrapolated price of stock and i found it in your video
    Thanks a lot for your time

  • @orenka1991
    @orenka1991 4 ปีที่แล้ว +2

    I am kinda new to machine learning and I never made any projects, but the fact that the result matched almost perfectly made me a bit suspicious about the method you use here.
    My first observation would be that the usage of scale would bound all result between the training dataset maximum and minimum, so there is no way that you could get a higher price as a prediction than the highest number found in the training dataset.
    My second obesrvation is about the actual training dataset. According to my knowledge testing dataset should not be included in the training data. I guess this is the reason it got the prediction so perfectly.
    I would suggest creating a dataset by actual % returns day by day or week by week. Maybe setting up some technical indicators. Volatility data, VIX, SP500 prices or anything should help predicting better the price in my opinion.
    However as commented by others already, pricemovements are not easy to predict and entire businesses are built to figure it out and still fail to beat the market.
    Thank you for the video! It was helpful to understand better how ML works in practice :)

  • @MrEmzeezy
    @MrEmzeezy 4 ปีที่แล้ว +7

    Good job, but I think you only wrote simple moving average using RNN. can you expand the dates and see what prices it predicts? THANK YOU for your tutorial!

    • @omkarmasal2148
      @omkarmasal2148 4 ปีที่แล้ว

      What if I want to predict the for the date that is not in my train dataset i.e I would use my whole dataset as training dataset and would create a module 2 predict the future price?

  • @sriadityab4794
    @sriadityab4794 3 ปีที่แล้ว +7

    Could you also please explain how to do cross-validation and hyperparameter tuning using LSTM?

  • @jjpmip
    @jjpmip 8 หลายเดือนก่อน

    Amazing video. It went thru everything from start to finish and explained it very clear and was easy to understand what was exactly going on and how things worked. Thanks for such a great video.

  • @AMA_RILDO
    @AMA_RILDO 2 ปีที่แล้ว

    I’m always enjoy and bless the people like you who teaching cool stuff

  • @ajumadryn
    @ajumadryn 4 ปีที่แล้ว +51

    I'd see a year backtest ;)

  • @MrArindamd
    @MrArindamd 2 ปีที่แล้ว +7

    First of all , thanks for a wonderful session. One question about scaling though. Shouldn't the MinMaxScaler be used to fit_transform the training data and then use the "fitted" scaler to the test data ?

    • @raghavverma120
      @raghavverma120 2 ปีที่แล้ว +3

      Yeah! There was information leak in this demonstration

  • @anshumansingh2146
    @anshumansingh2146 4 ปีที่แล้ว +1

    Very well planned video. This predictor can be helpful for getting trends and can be awesome. Thank You

  • @ChillbabaKaGyan
    @ChillbabaKaGyan 4 ปีที่แล้ว

    Your video was very much helpful for me to learn and understand ML with stock market price prediction.
    Keep making such useful videos sir.
    Thank you once again for your time and efforts.

  • @bangladesh6027
    @bangladesh6027 4 ปีที่แล้ว +145

    I can now say I've watched someone piss into the wind for 49 minutes

    • @devfromthefuture506
      @devfromthefuture506 4 ปีที่แล้ว +2

      Why?

    • @nczioox1116
      @nczioox1116 4 ปีที่แล้ว +4

      It can be done. Look up billionaire mathematician Jim Simons

    • @ClearVista
      @ClearVista 4 ปีที่แล้ว +2

      @@nczioox1116 I see this as being more useful for Options

    • @Zwiesel66
      @Zwiesel66 3 ปีที่แล้ว +1

      I like the metaphor 👍

    • @kacperogorek3958
      @kacperogorek3958 3 ปีที่แล้ว +9

      ​@@nczioox1116 Yes - but the video shows the common missconception about stock price prediction with LSTMs. This model just adds random noise of small amplitude to previous values. It cannot predict anything, its structure is just unsuitable to do so.

  • @insoucyant
    @insoucyant 4 ปีที่แล้ว +4

    Great flow and explanations. Please keep uploading such wonderful videos. :)

    • @ComputerSciencecompsci112358
      @ComputerSciencecompsci112358  4 ปีที่แล้ว +2

      Thank you, I will

    • @pritigoel8662
      @pritigoel8662 3 ปีที่แล้ว +2

      @@ComputerSciencecompsci112358 I found an error
      predictions=model.predict(x_test)
      predictions=scaler.inverse_transform(predictions)
      Output:
      Valueerror: Found array with dim 3. Estimator expected

  • @cyberspider78910
    @cyberspider78910 3 ปีที่แล้ว

    One very promising application of this approach is path finding by robot vehicle where in it has to use earlier data to predict next step !!! and check using sensors that whether the step it is going to take has any obstacle or not and correct/update its trajocatory....see...its totally a different field of application but it will definitely work - just keep you mind open, fellas !! He is good at what he does..

  • @CuteWiz
    @CuteWiz ปีที่แล้ว +2

    I'm getting error in this line. Does anyone know what is the issue behind it ?
    Command: df = web.DataReader('AAPL', data_source='yahoo', start="2012-01-01", end="2019-12-17")
    Error: TypeError: string indices must be integers

    • @lucaartz
      @lucaartz ปีที่แล้ว +2

      import yfinance as yf and change the line of code to df = yf.download('AAPL', start='2012-01-01', end=end='2019-12-17'). It seems like yahoo changed their api and these changes broke compatibility with pandas datareader

    • @jalithakalsara971
      @jalithakalsara971 ปีที่แล้ว

      @@lucaartz thanks

    • @sibusisoharvey2652
      @sibusisoharvey2652 5 หลายเดือนก่อน +1

      you may also use data_source = 'stooq' you can receive the same data

  • @dreamtreater
    @dreamtreater 4 ปีที่แล้ว +9

    Knowing nothing about price movements, you just show a neural net 60 days of price 1 time, and then ask it: "oh oracle, what will price be the next day". It really needs more work than that. This is exactly what I was afraid of when deep learning was made more available. Just fire a DL at everything you don't grasp. Waste some electricity while you're at it.

  • @cudanakiju0
    @cudanakiju0 3 ปีที่แล้ว +6

    It would be super useful if you could provide the raw code as well

  • @boleideng5707
    @boleideng5707 3 ปีที่แล้ว +1

    Cool video. But LSTM is not working so well here. Baseline test: if you simply predict the next day's stock price to be THE SAME as this day, you get an RMSE of 2.25 or so.

  • @Baranoeda
    @Baranoeda 3 ปีที่แล้ว +1

    I don't know if the author does not see this himself, or? The reason that the predicted graph follows the real one so close is that it only predicts 1 day into the future each time. If it would actually create the prediced yellow line ONLY based on the data up to mid 2018, that would be completely revolutionary. But of course, it is not. Its only predicting next day all the time. If I predicted next days close completely random +/- 1% it would look approximately the same.

  • @tlayta8823
    @tlayta8823 3 ปีที่แล้ว +6

    Hello great Video really helpful for understanding the concepts of LSTM models and stock price prediction 😊!
    I just have one question how can we add a dropout function in order to reduce overfitting and improve the performance of the model ?

    • @rohanshah8129
      @rohanshah8129 2 ปีที่แล้ว +1

      Add it after your Lstm layer in similar way we do for ANN.

  • @bruceaswann934
    @bruceaswann934 2 ปีที่แล้ว +29

    To be a super-trader, you'll need an edge to overcome the laws of probability and the uncertainty of the marketplace. That edge comes from information flow, the ability to correct your habits in terms of the market's characteristics, and being able to learn from people who know more than you, cut losses, expand your information network, ferret out ideas, and take recommendations. You can seek more guidance from Paulson Dmitriev his guidance got me this far.

  • @R-Waze
    @R-Waze 3 ปีที่แล้ว

    More videos like this, with different type of ML technique for stock prediction or Sell prediction in industry (like distribution), with more variety of technique, but with the same type of slow explanation. Super video, you definitely win my sub with this one. Thanks from the silent majority! 🤔

  • @nialloconnor9686
    @nialloconnor9686 2 ปีที่แล้ว +1

    With 3/1 risk reward you only need 50% on the model to make 10% gains on every ten trades. Training the model on only the closing prices is the wrong approach. You need open low high close and volume to correctly see the flow of money. And you only need the model to predict a day or two ahead. Thats it :-)

  • @gusinthecloud
    @gusinthecloud 4 ปีที่แล้ว +13

    awesome, thank you very much for this video!! A big Hug from Argentina!!

    • @manuelpatricioacuna59
      @manuelpatricioacuna59 3 ปีที่แล้ว

      Hola. Acabo de ver este video. Has intentado usar el código para invertir? De ser así, q tal salió todo?

  • @laurahaydee6007
    @laurahaydee6007 2 ปีที่แล้ว +4

    Thank you so much for this tutorial, it was very helpful and I learned a great deal :) I have a question, if I want to predict more days should I change the number of neurons? Could you clarify this, please?

    • @rohanshah8129
      @rohanshah8129 2 ปีที่แล้ว

      You will need to use for loop on the last cell he made for predicting next day value. The for loop will help to execute same lines of code for how many days you want to predict in future.

  • @surendra1990
    @surendra1990 2 ปีที่แล้ว

    in trading 0.1% matters. so these type of models are not going to help at all. unless they are constantly adjusted n number of times for the sample size taken to train the model, hardly any practical use. but an excellent way to begin with. THE EFFROTS ARE HIGHLY APRRECIATED. A BIG THANK YOU.

  • @loganathansiva7063
    @loganathansiva7063 2 ปีที่แล้ว

    Thank you for your valuable sharing predictions on stock prices in a simple manner and lucid way of expressions.

  • @moddinski
    @moddinski 4 ปีที่แล้ว +5

    this is nice as a thought experiment, but you'll loose your money if you use this for real. There is no edge or competitive advantage to be found by using this model.

  • @errolm8313
    @errolm8313 4 ปีที่แล้ว +3

    thank you for this! Im new to python and was wanting to hone my skills and thought I'd embark a project to predict the stock price of a company.... one question...why didnt you use time series analysis? is the LSTM method more useful than time series analysis for predictions?

  • @tigerbear3038
    @tigerbear3038 3 ปีที่แล้ว +2

    Can you explain what you are doing? It feels like you are just telling us what to type and not explaining what the code is actually doing.

  • @swarnimvarshneya6944
    @swarnimvarshneya6944 ปีที่แล้ว +2

    string indices must be integers - getting this error

  • @stefano8936
    @stefano8936 3 ปีที่แล้ว +5

    I haven't spot the trick, but that result looks a bit too much accurate, according to my experience

    • @vornamenachname906
      @vornamenachname906 3 ปีที่แล้ว

      yep but they dont care. they fell for "invest 250€ in amazon for second income" too.
      you cant help these people

  • @pigmonpiggy5943
    @pigmonpiggy5943 4 ปีที่แล้ว +11

    Thanks for the great video. Question: 1. Is there a way for LSTM to intake more than one variable? For example, using all the variable such as Close, Open, High and Low as input variable. 2.From what i see you are doing, is the LSTM a sliding window, using 60 data point to predict the 61st data point? How does that work for the testing dataset? Thank you

    • @lucasavila6928
      @lucasavila6928 4 ปีที่แล้ว +9

      Hi! Regarding 1 yes, they're multi-variable LSTM. It's pretty similar to the example showed in the video, the main difference is that your X data instead of having a shape of [ feature1_a, feature1_b, feature1_c, ..] its going to have a shape like [ [feature1_a, feature2_a, feature3_a, ..], [feature1_b, feature2_b, feature3_b, ...] ]. Before you had one variable as input and now you have multiple variables per input (thus the array).

    • @evantarzian8495
      @evantarzian8495 4 ปีที่แล้ว

      @@lucasavila6928 Hi Lucas. Really appreciate the video. Very helpful. Could you provide an example of the #Reshape the Data step using both Closing Price and Volume?
      Why could you not just replace the number of features from 1 to 2 as in the code below?
      x_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 2))
      x_train.shape

    • @koushik7604
      @koushik7604 4 ปีที่แล้ว +1

      Yes, all other variables can be incorporated, that is called multi-input time series. It is definitely a sliding window based approach and can be extended beyond a single day ahead forecast.

  • @user-sb1wq6wj1c
    @user-sb1wq6wj1c 11 หลายเดือนก่อน

    you are the big pro in trading! thank you for sharing your experience😄

  • @ivanpize
    @ivanpize 4 ปีที่แล้ว +1

    Thank you a lot for this sharing of knowledge. A question: ........ did you predict two years (2018-2020) at once? ...... OR ........ you have predicted day by day (or week) every day during two years ???????

  • @wisuthantanong1927
    @wisuthantanong1927 4 ปีที่แล้ว +17

    spoiler: prediction is of by 5-6%
    279.7399 vs 263.66394

    • @dreamtreater
      @dreamtreater 4 ปีที่แล้ว +6

      It's off, not of

    • @sdolo222
      @sdolo222 4 ปีที่แล้ว +2

      That's still pretty impressive I'd say

    • @Mark-ms9yd
      @Mark-ms9yd 4 ปีที่แล้ว +3

      5-6% a big difference

    • @HarshaSuranjith
      @HarshaSuranjith 4 ปีที่แล้ว +12

      I don't think this is a tutorial about designing an efficient model, but the basics of prediction using machine learning.

    • @phillipotey9736
      @phillipotey9736 3 ปีที่แล้ว

      It was a validation loss if 70000% bro what do you mean? Best o got with this method is 61% accurate

  • @andrefonzar6222
    @andrefonzar6222 4 ปีที่แล้ว +6

    Thanks for the video! I also got a question, how can you extend the prediction for the next 60 days for example ? thanks

    • @hjluna7760
      @hjluna7760 4 ปีที่แล้ว +1

      same question

    • @EnochAppiah
      @EnochAppiah 4 ปีที่แล้ว +2

      Try using incremental (online) learning. Create a loop to predict daily whiles updating your data with the predicted values incrementally.

  • @philipjacob7609
    @philipjacob7609 ปีที่แล้ว +1

    I don’t know why I can’t mine can’t display the prices it’s telling me type error

  • @koushik7604
    @koushik7604 4 ปีที่แล้ว +1

    It's an univariate time series and you are making a single day ahead forecast. However, that is not very useful from the business perspective. Try to incorporate other variables like high and low prices to train the model.

  • @holaahora7527
    @holaahora7527 4 ปีที่แล้ว +7

    Great video! Can someone explain to me why the input layer has 50 neurons and we pass 60 close prices each time, please? I thought that the number of neurons had to match with the number of inputs that we were passing.
    Thanks in advance :)

  • @jianzuo4389
    @jianzuo4389 3 ปีที่แล้ว +5

    Hello, Thanks a lot for this interesting instruction about stock price prediction.
    I am working on the prediction related to battery performance deterioration, so I have a few questions on the prediction part of the prediction algorithm. To my knowledge, the prediction part you proposed in the video can only make one step ahead prediction, right? Though the first algorithm you create a NumPy array contains test close stock price (many rows), but in your
    pred function, you iterate the prediction only based on the x_test, without the predicted close stock values. Is it possible to overcome this to help make a real prediction that can predict the stock price for a longer period, like 10 days, one month? Thank you very much.

    • @rohanshah8129
      @rohanshah8129 2 ปีที่แล้ว

      This video is simply to demonstrate the implementation of LSTM. There are many factors to consider while making real predictions. Imagine if this was effecient way then wont all the LSTM algorithm makers be making huge profit 🤍

  • @ciaran7780
    @ciaran7780 3 ปีที่แล้ว

    you don't need neural networks to predict the stock market's price action. As it is already straight forward enough. Real pricing isn't a given, but it's degrees of freedoms are fairly constrained.

  • @weezyfbaby61
    @weezyfbaby61 4 ปีที่แล้ว +8

    Thank you for the video, it is helpful to understand the logic behind this. Let suppose I want to add sentiments as another dimension for prediction, how would you include this in the code?

  • @waelzayat2830
    @waelzayat2830 4 ปีที่แล้ว +3

    That's pretty cool! thank you man. I just didn't know why you imported the pandas

  • @calcwithfab1192
    @calcwithfab1192 2 ปีที่แล้ว +1

    I think the rmse that you calculated is the (mean)^2, not the mean of squares.

  • @AkhzarFarhan
    @AkhzarFarhan 4 ปีที่แล้ว

    You should probably use sentiment analysis for prediction rather than past closing prices because stock prices much depend upon the sentiment of people rather than its old price.

  • @glypton
    @glypton 3 ปีที่แล้ว +17

    It’s very important that the programmer should deeply understand the market as well to prevent the creation of BS like presented here! These results only seem to be close to the actual price, but in reality it’s 95% noisy!