Building the Gradient Descent Algorithm in 15 Minutes | Coding Challenge

  Рет қаралды 59,065

Nicholas Renotte

Nicholas Renotte

Күн бұрын

What's happening guys, welcome to the second episode of CodeThat!
In this ep I try to build a regression machine learning model using a gradient descent algorithm we build completely from scratch using Python. The only dependency we use in the challenge is numpy!
Oh, and don't forget to connect with me!
LinkedIn: bit.ly/324Epgo
Facebook: bit.ly/3mB1sZD
GitHub: bit.ly/3mDJllD
Patreon: bit.ly/2OCn3UW
Join the Discussion on Discord: bit.ly/3dQiZsV
Happy coding!
Nick
P.s. Let me know how you go and drop a comment if you need a hand!
#machinelearning #codingchallenge #gradientdescent

Пікірлер: 95
@javierjdaza
@javierjdaza Жыл бұрын
i need to say this: you are the gamechanger here!! as a data scientist +2 years of experience, i ALWAYS learn something new with your content! please nich, never stop doing this things, and also, never cut your smile in your face, even if your are having bugs!! thanks for everything
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Thank you so much for your kind words @javierjdaza!
@Beowulf245
@Beowulf245 Жыл бұрын
I've been following your channel for a while now and I always find new cool stuff here. Keep up the good work, it's really helpful. Also, I love your positive personality, you really make complex stuff look entertaining.
@nikitaandriievskyi3448
@nikitaandriievskyi3448 Жыл бұрын
Once you initialized lr to 0.0, I knew you were going to forget to change it lol. Love the challenges tho, keep doing them, I think it would be cool to see how you implement a neural network from scratch
@NicholasRenotte
@NicholasRenotte Жыл бұрын
I'm still kicking myself that it was the lr that tripped me up 😅, literally it's so different coding under pressure stuff that should just flow goes out the window. OHHH yeah, I thought about a good challenge building NNs while I was at the gym, stay tuned!
@thegeeksides
@thegeeksides Жыл бұрын
@@NicholasRenotte did you ever make that video? A NN from scratch for hadnwritten digits (MNIST) classification would be so awesome!
@lakshman587
@lakshman587 Жыл бұрын
Set the time limit to 20 mins from next time Because you are even explaining us. This is really awesome!!
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Thanks a million @Lakshman!! I try to keep it pretty tight so it’s a good challenge otherwise I know I’ll just talk for 22 minutes anyway😅
@alyt9870
@alyt9870 Жыл бұрын
Love the channel Nicholas, have recently graduated from an NLP Master's degree and seeing you explain stuff in a simpler way and your coding challenges is really helping me connect with the material I've learned! Keep it up and I'll keep watching!
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Woah congrats @Ally 🎊 🎉 glad you’re enjoying the challenges, plenty more to come!!
@BOGABOOfull
@BOGABOOfull Жыл бұрын
Awesome video !! It's preety cool to see such theoretical concepts coded and explained like this. Keep going Nich !!
@NicholasRenotte
@NicholasRenotte Жыл бұрын
YESSSS, right?! Glad you liked it Miguel!
@spencerbertsch7375
@spencerbertsch7375 Жыл бұрын
Hey Nicholas! Love your channel and I'm really appreciating these 15 minute coding challenges - please keep it up! Also, you can disable those annoying VS Code popups you ran into at 8:35 by going to Code > Preferences > Settings, then typing "editor.hover.enable", then unchecking the "Editor > Hover" option. Hope that's useful!
@NicholasRenotte
@NicholasRenotte Жыл бұрын
You are a lifesaver @Spencer, will do it next time i'm on the streaming rig!
@VictorGiustiniPerez_
@VictorGiustiniPerez_ Жыл бұрын
Really nice video! Love the energy and the enthusiasm. Thanks for the help!
@einsteinsboi
@einsteinsboi Жыл бұрын
Amazing! I'm learning so much watching you code. Thank you for sharing.
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Thanks a mil @einsteinboi!!
@williamstephenjones3863
@williamstephenjones3863 Жыл бұрын
This is a very novel and cool way to teach coding. I really enjoyed it, and it was good to see you troubleshoot and get stuff wrong.
@leonardputtmann8404
@leonardputtmann8404 Жыл бұрын
This was oddly intense. Great job Nicholas! Even though you ran out of time, this video is still a win to me. 😉
@NicholasRenotte
@NicholasRenotte Жыл бұрын
It definitely felt intense at the time Leonard 😅, the pressure is definitely real. I don't know what it is, but coding under pressure is just a completely different beast. Thanks a million, I'll take the win and thanks for checking it out!
@Powercube7
@Powercube7 Жыл бұрын
the zoom in on the unsaved icon was personal 💀 one of the reasons why I use autosave
@NicholasRenotte
@NicholasRenotte Жыл бұрын
😅 I was angry at myself when editing, I had to make a point of it lol😂
@juliansteden2980
@juliansteden2980 Жыл бұрын
Great Video! Would be cool to come back to this and add visualization during gradient descend using matplotlib and show what is actually happening. For example drawing data points, regression line, individual loss between line and data points and showing stats like current step, w, b, total loss! :)
@NicholasRenotte
@NicholasRenotte Жыл бұрын
OHHHH MANNN, I thought about doing that but I was debating whether I'd hit the 15 minute deadline already. Good suggestion @Julian!
@spicytuna08
@spicytuna08 Жыл бұрын
wow. you make the subject come alive with excitements and simplicity. you are really gifted. i will take you over hard to understand but smart Ph.D professors from Ivy league any day.
@cavaliereoscuro1098
@cavaliereoscuro1098 Жыл бұрын
the essence of Deep learning in a few lines of code... awesome
@darshitgoyani2094
@darshitgoyani2094 Жыл бұрын
Lots of Thanks, Nick :)
@akumlonglongkumer3824
@akumlonglongkumer3824 Жыл бұрын
Pretty impressive. This is awesome. Cheers
@luis96xd
@luis96xd Жыл бұрын
Great video, I like this kind of video where you code some AI task counterclock, you teach us the concepts and show us the reality of implementing it👏 Well explained 😄👍
@Felicia-126
@Felicia-126 Жыл бұрын
Amazing video!! Thank you so much
@sergioquijano7721
@sergioquijano7721 Жыл бұрын
You are so good at explaining these complicated concepts. Also, if you want to close the explore tab in VSCode try: Ctrl + b
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Legend, thanks a million @Sergio!!
@sergioquijano7721
@sergioquijano7721 Жыл бұрын
@@NicholasRenotte :D I can give you more shortcuts if you tell me where I can learn more about Machine Learning concepts as you explained
@NicholasRenotte
@NicholasRenotte Жыл бұрын
@@sergioquijano7721 DONE, fair trade!! Been studying this book in a ton of depth this week: themlbook.com/ I threw my own spin on the grad descent example but the fundamentals are in there!
@GallantryX
@GallantryX 10 ай бұрын
Wow. This youtuber has only 197k. For this absolutely high-quality videos. you deserver more than 1m+, only thing to say, is keep grinding, and you'll get to it.
@kashishrajput4934
@kashishrajput4934 Жыл бұрын
That's so informative thank you so much
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Glad you enjoyed it @Kashish!!
@lvjianlvj4604
@lvjianlvj4604 Жыл бұрын
I really like this video. It is great!
@brunospfc8511
@brunospfc8511 Жыл бұрын
i'll give you half a win, since it was a small detail
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Cheers @brunospfc!!
@ibrahim47x
@ibrahim47x Жыл бұрын
ChatGPT won this challenge instantaneously lol : import numpy as np # Set the learning rate learning_rate = 0.01 # Set the number of iterations num_iterations = 1000 # Define the data points X = np.array([[0, 1], [1, 0], [1, 1], [0, 0]]) y = np.array([1, 1, 0, 0]) # Initialize the weights weights = np.zeros(X.shape[1]) # Train the model for i in range(num_iterations): # Compute the predicted values y_pred = 1 / (1 + np.exp(-1 * np.dot(X, weights))) # Compute the error error = y - y_pred # Update the weights weights += learning_rate * np.dot(X.T, error) # Print the weights print("Weights:", weights) A.I. description of the code: "This script defines a simple dataset with four data points and trains a model using the gradient descent algorithm to learn the weights that minimize the error between the predicted values and the true values. The model uses a sigmoid activation function to make predictions. The script initializes the weights to zeros, and then iteratively updates the weights using the gradient descent algorithm, computing the predicted values, the error, and the gradient of the error with respect to the weights. The learning rate determines the size of the step taken in each iteration. After training the model, the final weights are printed out. You can use these weights to make predictions on new data points by computing the dot product of the data points and the weights, and applying the sigmoid function."
@dipendrathakuri6429
@dipendrathakuri6429 Жыл бұрын
I think you missed dividing the derivative by 2. Because in the formula for cost function, we have (1/2*no. of training data)*sum of squared error, when we take the derivative, 2 from dldw and 1/2 from cost function cancel each other. Anyway, it was a cool video, keep up the good work brother
@11harinair
@11harinair Жыл бұрын
Thanks for the video, subscribed! A suggestion : this small change to your code would demonstrate a real-world gradient descent solution for linear regression with noisy data. E.g. : x = np.random.randn(20,1) noise = np.random.randn(20,1)/10 # w = 5.8, b = -231.9 y = 5.8*x - 231.9 + noise
@rokunuzjahanrudro7571
@rokunuzjahanrudro7571 8 ай бұрын
Great video 🎉🎉
@_danfiz
@_danfiz Жыл бұрын
This is cool, seeing it realtime.
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Glad you enjoyed it @NHMI!
@alfathterry7215
@alfathterry7215 3 ай бұрын
this is gold!
@adipurnomo5683
@adipurnomo5683 Жыл бұрын
Nice implementation bro
@grahamfernando8775
@grahamfernando8775 Жыл бұрын
Can you please do a tesorflow instance segmentation video using Mask RCNN. There isn't much of a KZbin content related to this online.
@birgenc5961
@birgenc5961 Жыл бұрын
Love it!
@terrencejeffersoncimafranc100
@terrencejeffersoncimafranc100 Жыл бұрын
Can you explain the notears algorithm? It would be a great help.
@jakekisiel7399
@jakekisiel7399 Жыл бұрын
Is there any other machine learning/NVIDIA Jetson video tutorials you would recommend?
@rrrfamilyrashriderockers6891
@rrrfamilyrashriderockers6891 Жыл бұрын
so can you please do this algorithm for multiple variables
@SomebodythatIusetoknow123
@SomebodythatIusetoknow123 3 ай бұрын
Thee learning raaate haha cool vid !
@majdabualnour
@majdabualnour Жыл бұрын
I realy love your vedio the idea of the vedio is insain and i realy like it
@NicholasRenotte
@NicholasRenotte Жыл бұрын
So stoked you liked it 🙏
@aiforyounow
@aiforyounow Жыл бұрын
Nick but I thought there are existing algorithms that u can feed your data into ? I love the way you’re doing it though but is it good doing your style or used existing ones ??
@NicholasRenotte
@NicholasRenotte Жыл бұрын
100% use the prebuilt ones in sklearn, this is more to understand how they work and to provide intuition for tuning and preprocessing!! Good question 👍
@aiforyounow
@aiforyounow Жыл бұрын
@@NicholasRenotte that’s why I call u Khalid of deep learning
@alexisjulianrojashuamani1582
@alexisjulianrojashuamani1582 Жыл бұрын
U R GOD MAN, so much thanks
@meguellatiyounes8659
@meguellatiyounes8659 Жыл бұрын
I wonder how much i takes the backpropagation algorithm ?
@ShiftKoncepts
@ShiftKoncepts 3 ай бұрын
Does gradient descent work for polynomial with multi-variable problems?
@adipurnomo5683
@adipurnomo5683 Жыл бұрын
Bro, how to implement gradient descent as weight in K nearest neighbor ?
@kartik_exe_
@kartik_exe_ 10 ай бұрын
how amazing it is that he set timer for 15 mins and the vid is 22 mins long
@abdulbary3668
@abdulbary3668 Жыл бұрын
You should create a model to Reduce the pressure during last minutes. Such that finding an optimal time tolerance (+-) ( 15+-b) 😂😂😂😂. 😢 but we need more videos like this to have good dataset 😂😂🎉. Thanks man
@MSCAIMLRBRITHANYA
@MSCAIMLRBRITHANYA Жыл бұрын
oh god! you forgot to save and i involuntarily kept shouting SAVE IT! SAVE IT!
@msa7202
@msa7202 Жыл бұрын
Please do a video building a NN from scrath!!
@user-tx3mo1ez2n
@user-tx3mo1ez2n Жыл бұрын
why is it necessary for x and y to be list of lists ?
@patrickm.39
@patrickm.39 Жыл бұрын
Are you reading my mind or something? Every time I'm stuck on a topic, you drop a video about it...
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Ayyyy, so glad you like it @Patrick. For the last two weeks I've just been making videos on stuff I find hard or want to get my head around I figure it's not just me staring there at some of these concepts like huh?!? Thanks for checking it out!!
@Pedrommelos
@Pedrommelos Жыл бұрын
hey man! I have a friend from Lyon and you guys have the same surname, haha Any chance you have roots from there?
@rverm1000
@rverm1000 Жыл бұрын
where is it used? why?
@ChangKaiHua300
@ChangKaiHua300 Жыл бұрын
Man you actually made it, unless you say tuning hyperparameter is part of the challenge lol
@NicholasRenotte
@NicholasRenotte Жыл бұрын
You're my new best friend @Kai-Hua, I could've just wrote it off and said "So that's a regression model with gradient descent...and nooooowww, we'll tune it!"
@vialomur__vialomur5682
@vialomur__vialomur5682 Жыл бұрын
Thanks waiting for the part 5 forza
@MrElectrecity
@MrElectrecity Жыл бұрын
Please check the Auto Save in file drop down list it's really time saver 😃 I need to see the video many times to understand what are you doing But great work I love all what you do Thumb up 👍👍
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Thanks for the suggestion @MrElectrecity!
@quadropheniaguy9811
@quadropheniaguy9811 Жыл бұрын
Could you please upload correct code to github? I lost track of your logic after "def descend () etc".
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Correct code is on there @Quadrophenia, not working?
@user-uf3qh3fr7d
@user-uf3qh3fr7d Жыл бұрын
👍👍👍
@carlosvasquez-xp8ei
@carlosvasquez-xp8ei Жыл бұрын
Great video. Set time to 20 mins.
@lakshman587
@lakshman587 Жыл бұрын
Gift card not valid :( But it was fun! You are amazing!!
@NicholasRenotte
@NicholasRenotte Жыл бұрын
Got claimed super fast this time @Lakshman!!
@lakshman587
@lakshman587 Жыл бұрын
@@NicholasRenotte My bad I have turned on the notification of your channel! Waiting for the next code that challenge!!!! Hope you win next time! 🤞🤞🤞
@philtoa334
@philtoa334 Жыл бұрын
Vert nice
@NicholasRenotte
@NicholasRenotte Жыл бұрын
HEYYYYY PHIL!! Long time no see, thanks a mil!!
@nuke4496
@nuke4496 8 ай бұрын
LOLLLL
@schubiduba1
@schubiduba1 Жыл бұрын
Was too fast for me
@nikaize
@nikaize 3 ай бұрын
😂😂😂
@winglight2008
@winglight2008 Жыл бұрын
Where's my $50 gift card? Lol
@Harshadswe123
@Harshadswe123 Жыл бұрын
I can do this more efficiently
@aso_o.111
@aso_o.111 Жыл бұрын
You can contact us on telegram
@NicholasRenotte
@NicholasRenotte Жыл бұрын
You can contact me on youtube
Gradient Descent, Step-by-Step
23:54
StatQuest with Josh Starmer
Рет қаралды 1,3 МЛН
Building a Machine Learning API in 15 Minutes | Coding Challenge
20:04
Nicholas Renotte
Рет қаралды 124 М.
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 58 МЛН
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 25 МЛН
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 57 МЛН
Building a Neural Network with PyTorch in 15 Minutes | Coding Challenge
20:34
The Most Important Algorithm in Machine Learning
40:08
Artem Kirsanov
Рет қаралды 332 М.
Gradient Descent From Scratch In Python
42:39
Dataquest
Рет қаралды 17 М.
Linear Regression From Scratch in Python (Mathematical)
24:38
NeuralNine
Рет қаралды 160 М.
Solve any equation using gradient descent
9:05
Edgar Programmator
Рет қаралды 52 М.
ML Was Hard Until I Learned These 5 Secrets!
13:11
Boris Meinardus
Рет қаралды 239 М.
Intro to Gradient Descent || Optimizing High-Dimensional Equations
11:04
Dr. Trefor Bazett
Рет қаралды 62 М.
22. Gradient Descent: Downhill to a Minimum
52:44
MIT OpenCourseWare
Рет қаралды 76 М.
СТРАШНЫЙ ВИРУС НА МАКБУК
0:39
Кринжовый чел
Рет қаралды 1,1 МЛН
Смартфон УЛУЧШАЕТ ЗРЕНИЕ!?
0:41
ÉЖИ АКСЁНОВ
Рет қаралды 624 М.
Clicks чехол-клавиатура для iPhone ⌨️
0:59
ОБСЛУЖИЛИ САМЫЙ ГРЯЗНЫЙ ПК
1:00
VA-PC
Рет қаралды 2 МЛН
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 7 МЛН