Logistic Regression in Python from Scratch | Simply Explained
HTML-код
- Опубликовано: 27 июл 2024
- Implement Logistic Regression in Python from Scratch ! In this video, we will implement Logistic Regression in Python from Scratch. We will not use any build in models, but we will understand the code behind the Logistic Regression in Python.
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
This is Your Lane to Machine Learning ⭐
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
📕 Download Implementation Code with Dataset : github.com/Jaimin09/Coding-La...
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
✔ What is Logistic Regression ? : • Logistic Regression Ma...
✔ Cost Function in Logistic Regression : • Logistic Regression Co...
✔ Gradient Descent in Logistic Regression : • Logistic Regression Gr...
✔ Derivative of Cost Function for Logistic Regression : • Derivative of Cost fun...
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
Know the difference between Artificial Intelligence, Machine Learning, Deep Learning and Data Science, here : • Artificial Intelligenc...
Complete Logistic Regression Playlist : • Logistic Regression Ma...
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
Subscribe to my channel, because I upload a new Machine Learning video every week : / @codinglane
If you found this video valuable, then hit the *_like_* button👍, and don't forget to *_subscribe_* ▶ to my channel as I upload a new Machine Learning Tutorial every week.
@Quran and Hadith yes
@Quran and Hadith yes
Very few people explain things mathematically and a very few people want a mathematical explanation. People just want to code without understanding the algorithm. You and your subscribers are the best :)
Thank you so much for such a good compliment 😊
Please don't stop uploading videos it's really really superb explanation in a precise manner. Great job keep it up bro 😎
A very good video, been searching for something like this for so long. Finally found it. Thanks bro.
Thank You!
Man for the past 2 days i have been searching the explanation
Man you rocked it .Keep going brother
Thanks a lot ! 😁
I don't have words for give compliment for your explanation bro.
MOST CLEAR EXPLANATION I EVER SEEN BEFORE. 🍺🥂
And I don’t have words to appreciate your comment ! Thank you very much ! It really means alot to me
Thank you so much you really helped me start my ML journey
I was searching a lot and finally bro!!! I got you!!!!! thanks a lot
Thank you so much! This means a lot to me.
thanks, very good video 👍
500th like by me, good luck👍
Thanks for sharing these videos😀. Your all videos are informative and make it so simple for me to understand the concept🤓.
It's my pleasure. Happy to hear that! 🙂
in your cost where did you get y and from cause you never defined them
well , in your cost function video you told that
dCost/dW = (A-Y).X
but in code you wrote that
dCost/dW = (1/m)(A-Y).X
should I multiply (1/m) or not?please tell me bro
Hey, thanks a lot for the video!
So I'm facing a major problem. When I run the model, I am getting cost as NaN for every iteration after the 0th iteration.
Why is this happening? How do I fix this?
For context, I am using a different dataset (adult census income dataset from Kaggle) but all the preprocessing has been done and all the columns have numerical values.
Its because you might be taking very large “learning_rate”
Try to reduce its value by 100 times or 10000 times or may be more.
Once you see cost function takes some value which is not NaN, you can increase the learning_rate or adjust it to train the model faster.
If still it shows NaN, then check if you have implemented the equations of logistic regression properly or not. A slight change in equation can also cause model not to train.
how to plot logistic regression ?
By implementing the same code it is showing an error: weight is not defined what should I do
Thanks a lot. your explanation was just awesome. Would you please make a similar video on Multiclass Logistic Regression from scratch? I am expecting it from you bro.
Thank you so much! And yea... I will try to make that video too
you just saved my life mate thx
you are awsome
thanks for this useful video .. I just have one question : I have a dataset for students performance in a course and I am required to split my dataset into 70% for training and 30% for testing without using sklearn .. How to do so?
For this you can learn numpy and pandas from any video tutorial. That will help you in all these sorts of data preprocessing.
you sir are a legend. I took several tutorials on machine learning , your videos are the only one that make sense to me. I don't know if you have any paid course out there, if you do please let me know, i will definitely purchase it. good luck :)
Thanks a lot for the compliment 😇. Means a lot. Currently, I don’t have any paid courses, hoping to make them in future!
Thanks for this video, it was very informative.
Could you please explain the formula you have used for accuracy in accuracy function?
Hi… I calculated error rate… which is % of wrong predictions and then subtracted it from 100
hi, I had been learning machine learning by my own and had seen many videos, your explanation was remarkable, keep going, there is a clarity after we listen to your videos, great great, all the best for making more videos on all algos of ML
Thank you so much ! I am elated after reading this. I am glad you find my videos helpful.
@@CodingLane certainly yes, kindly upload more videos which can teach us from the scratch so that it will be easy for us to understand better than blindly using the python machine learning libraries. Great job, keep going
Sure ! Thanks @@brindhasenthilkumar7871
Amazing job!
Thank you!
it was really helpful
Glad I could help!
keep it up man... you couldn't be better teaching...
Thank You so much !
Thanks for the video Jay 💙
Just a simple question, at 5:31: You used the method (reshape) to modify Y but the (transpose) to modify X!
Why don't we use transpose for both? I tried it and I think it works, otherwise you have other reason!
Thanks again for your amazing content 😄
You can perform the operation using reshape or transpose. Both are fine. There is no specific reason for me to use reshape instead of transpose. You can use any 😇
bro thank you for good video
You’re welcome!
Hi
At 1:11 you are uploading csv files for train and test.
I am using Google Colab.
Thus, the code to upload the files I got was
=files.upload()
Thus, how do I fit the same using Pandas as demonstrated by you?
Hello,
here are the ways to use the files on google colab and load into pandas:
towardsdatascience.com/3-ways-to-load-csv-files-into-colab-7c14fcbdcb92
Hope it helps!
Thank you for this video, it is really helpful.
Can you make a video on feature scaling from scratch?
Thanks for the suggestion… i will see if i can make a video on it
@@CodingLane Thank you for your support
would A > 0.5 get us a sum of correct predictions or just one class? can you please explain a bit clearly maybe i missed
Sure.
Let say if A = [0.2, 0.7, 0.8, 0.3, 0.4, 0.6]
Then A > 0.5 will be = [false, true, true, false, false, true]
And if you convert it into integer, then it will be, Afinal = [0, 1, 1, 0, 0, 1]
Thus, A initially were just probabilities. Now Afinal are predictions for class 0 and 1
Hope I made it clear now.
@@CodingLane hey thanks but accuracy is sum of all the correct predictions / total predictions meaning and apologies if I am wrong ... compared to y truth and y predict how many in [0, 1, 1, 0, 0, 1] were right / total , not simply > 0.5 which yes will simply separate the classes ... i did calculate it back yesterday and my accuracy was around 68 - 71 % .. Super sorry if i did it all wrong and big thanks again
def accuracy_manual(slope, intercept, X_test,Y_test):
predictions = np.dot(slope.T, X_test) + intercept
predictions_log =(sigmoid(predictions))
all_predictions=[1 if i >= 0.5 else 0 for i in predictions_log[0]]
print("all predictions == ", len(all_predictions))
count=0
for i in ap:
if Y_test[0][i] == all_predictions[i]:
count+=1
else:
pass
print("correct count ", count)
#alternate way
s= sum([all_predictions[i] == Y_test[0][i] for i in all_predictions])
print("correct count ", s)
#accuracy = correct count / total count
accuracy = count/len(all_predictions)
print("accuracy of model ", accuracy)
return accuracy
np.mean(P == y_test)
how to select best features to get the highest possible f1 score
very informative, you are the best continue
Thank You so much 😇 !!
@@CodingLane
i have a question that concerns boudary and logistic regression how can i contact you in person
@@babaabba9348 mail me on codeboosterjp@gmail.com
@@CodingLane
thank you so much mate
@@CodingLane
maybe it would be better that you delete your address
Great video. You made it seem easy. And Easy is good. Thanks a lot
Thank you so much ! I really appreciate it
Thanks bro
Your welcome !
Very Nice.
Thank you!
Please make more videos on ml algorithms
Thanks for the suggestion. Will also make videos on other ML algorithms. Though it might take some time.
Content is very good, but the presentation is not satisfactory.
Thank you for your feedback. I have tried to improve the presentation style in the newer videos. I hope you find it better.
sorry mate you need to slow down a bit
Okay 👍🏻
I love your explanation but please don't fake your accent. Its quite annoying.
Thank You Danish !
What do you mean by ''Fake your accent'' ?