From Scratch: How to Code Linear Regression in Python for Machine Learning Interviews!

preview_player
Показать описание
Linear Regression in Python | Gradient Descend | Data Science Interview Machine Learning Interview

Correction:
8:40 gradients should be divided by "m" instead of "n".

🟢Get all my free data science interview resources

// Comment
Got any questions? Something to add?
Write a comment below to chat.

// Let's connect on LinkedIn:

====================
Contents of this video:
====================
00:00 Linear Regression Overview
03:58 Gradient Descend
06:32 Linear Regression Implementation
10:48 Time and Space Complexity
Рекомендации по теме
Комментарии
Автор

Hi Ema. Thank you very much for your videos. Thanks to them I got a Senior Data Scientist position at Facebook. I will forever thank you for your exceedingly good work.

diegozpulido
Автор

Correction:
1. Thanks to Ji Xu - at 9:39, it should be divided by m instead of n.
2. Thanks to Hui Yi - at 9:39, beta_1 should be beta_other.

emma_ding
Автор

Very helpful video, clear and concise! One minor correction: at around 8:40 (updating the gradients in method compute_gradient()) I think you meant to divide by m instead of n.

XuJiBoY
Автор

One of the important interview questions that I've seen for linear regression is: "What are the linear regression assumptions"

cccspwn
Автор

Time complexity is assuming this is the code that would be used, which does not leverage GPU. With parallelization, a vector multiplication may be computed in constant time, reducing time complexity to O(M) from O(MN)

techedu
Автор

The explanation is very clear and concise! Thank you so much. Please keep it going.

jijyisme
Автор

I believe in the gradient descent step, it should be beta[i] -= (gradient_beta_other[i
] * learning_rare)
Since traversing down a slope requires taking the opposite sign of the computed the gradient

florachen
Автор

I like the step by step guide. And I learned a lot from your implementation.

jeoffleonora
Автор

Thank you for the videos, Emma, I am on the very last round of Amazon and Microsoft for senior data scientist and I am finding your material excellent for prep and review!!! One thing I cannot understand what does the subscript j mean? how is it any different than i (slide at min 6 and 6 30)

LuciaCasucci
Автор

Thanks for posting a great video. Quick question, I noticed that you chose iteration = 100 and learning rate = 0.01 here. Is there a relationship between iteration and learning rate, e.g. iteration*learning=1?

nanfengbb
Автор

Bear with my rusty math ....
Calculating derivative of y over betai, at 6:27, how come it become Xji? It is making more sense if it is the derivative of y_hat over betai... consistent to the earlier slide at 2:50?

梅鹏飞-ge
Автор

Hi Ema, thanks for your video. I wonder how we can explain concepts like gradient decent, maximum likelihood, loglikelihood verbally in an interview?

jamiew
Автор

Thanks for sharing the implementation details. The explanation at 10:30 was hard to understand, specifically the reasoning that "if yhat>y, derror_dy is negative and thats why we add". Beta is being updated here, so the gradient is wrt B, so before reaching the error, B goes through yhat, then yhat contributes to E. That slide shows dE/dy, but where is dy/dB? It feels like a part of the chain rule was missing in that explanation, and directly jumped to "negative gradient" which includes dE/dy * dy/dB, but the latter term is not talked about in that slide.

Han-veuh
Автор

Hi Emma thanks for the video, but n shouldn't be in the compute_gradient function. it should be m instead

arieljiang
Автор

Waiting for the new video for a week! It's coming!

jessieshao
Автор

is the gradient computed correctly at 6:20? the negative sign seems to be missing when doing derivatives of error wrt to yhat

jiahuili
Автор

is this code too long for an interview?

wongkitlongmarcus