Linear Regression Model Techniques with Python, NumPy, pandas and Seaborn

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

ความคิดเห็น • 52

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

    Thank you Matt. You explain things so well. I've watched several of your videos and intend to watch more.

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

      Thanks very much. Glad it's helping.

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

    Thank you for your work and the video!

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

      Thanks. Glad it helped

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

    Thank you! Is this also good for predicting a range? Say 30 periods out?

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

      Glad it helped. It's tough to predict out that far, but yes it might give you something better than just guessing.

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

      @@MattMacarty thank you Matt!

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

    Thank you for this. I was looking for a way to code a trend line. With many traders it becomes subjective. This makes it more precise.

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

      Thanks. Glad it helped

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

      @@MattMacarty hi bro thank u so much for the video its help a lot , but could u tell me why we use the np log diff ?

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

      Great. Glad it helped.

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

      Glad it helped. Yes you can copy tables. see this video: th-cam.com/video/68XMlO9fciA/w-d-xo.html

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

      @@aimenslamat1264 The log change is referred to as the instantaneous rate of return and is commonly used to price securities, particularly derivatives

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

    Hi there, firstly great video! How would it be possible to add another variable to the trend line? So essentially it would be multiple linear regression

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

      Thanks. Generally two explanatory variables would be graphed as a plane.

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

    Hello Matt, first of all, thank you for your work. I have tried to reproduce this exercise and when executing the line
    'data = pdr.get_data_yahoo(stocks, start)'
    I get the following error message:
    'TypeError: string indices must be integers, not 'str'.
    I have tried to solve it in different ways, but nothing, it always gives me that message. I downloaded your code in case there was something written incorrectly, and it gives me the same error. Any suggestions?

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

      Thanks. The problem is the pandas_datareader has not kept up with changes to the yahoo finance API. The workaround is to install yfinance (pip install yfinance). Then it would be yfinance.download(stocks, start)

    • @vimalk78
      @vimalk78 2 หลายเดือนก่อน

      @@MattMacarty i also faced same issue.. can i send a github PR to update the notebook if already not updated?

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

      @@vimalk78 Sure I will post updated code using yfinance.

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

    Thank you sir for explaing the code in the detail

  • @Joe-xo2yd
    @Joe-xo2yd 2 ปีที่แล้ว

    Matt, if I wanted to take the first derivative of the linear regression function, how could I execute that? is there a certain package?

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

      Sure, you can use NumPy, SciPy, scikit-learn. Probably a number of others but that's what comes to mind.

  • @nicholasrackard-hilt1619
    @nicholasrackard-hilt1619 2 ปีที่แล้ว

    Thank you for the video!! How would I add another more trend lines to subset set specific times or dates? I am trying to plot my X and Y for 9 am 10am 12pm and have multiple trend lines. Hope that makes sense, thank you in advance!

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

      You mean for different time periods, say an hour for each? You should be able to subset the data and then run a regression on each subset.

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

    Very good Thank you.

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

    Could you possibly provide a link to the data set you actually used in this tutorial? I would like to follow it locally on my PC as I go through this. Thank you.

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

      Hi the data was downloaded from Yahoo finance. Here is a link to the notebook: github.com/mjmacarty/alphavantage

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

    Thank you Matt. Would like to know what is different btw "np.log().diff()" and "pct_change().cumsum()", I've tried those two syntax then got a different result. Could you pls solve this question? Thanks again Matt.

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

      pct_change is E/B - 1, np.log is LN(E/B). LN is a continuously compounding rate.

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

    Very Nice, Hello Matt, in the section "trend as a technical indicateur", how to put the value of the trend line in a dataframe to detect later when it cross the curve ? Thank you. 👍👍

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

      You need the slope and intercept coefficient and then you can create a column with the trend line

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

      @@MattMacarty Yess my friend it s exactly what i want, maybe if you have a small example ? Thnx.

  • @mamunmd.abdullahall5122
    @mamunmd.abdullahall5122 ปีที่แล้ว

    import pandas_datareader as pdr is not working , what shoul di do

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

      This probably means it is not installed. From the command line run pip install pandas-datareader

    • @marcus.guitarist
      @marcus.guitarist ปีที่แล้ว

      @@MattMacarty looks like Yahoo might have changed something

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

    Hi I am running into this error:
    No data fetched using 'YahooDailyReader'

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

      Can you send me the line of code that caused the error?

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

    what to do if the x-axis is time series ?

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

      Probably the easiest thing to do is make time the independent variable.

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

    i get error: "ModuleNotFoundError: No module named 'pandas_datareader'"

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

      Hi this means you need to install it. Run !pip install pandas-datareader in a code cell in your notebook

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

    Correlation != Causality !!!

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

    i got two points

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

      Hi. You can download the notebook I used here: alphabench.com/data/python-linear-regression.html

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

      @@MattMacarty yeah i still got two points for spy and Google might be due to a crash

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

      do you want to look at my notebook when I finish it.

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

      changed the symbols still got two points using goog