Machine Learning Tutorial Python - 8: Logistic Regression (Binary Classification)

Sdílet
Vložit
  • čas přidán 23. 06. 2024
  • Logistic regression is used for classification problems in machine learning. This tutorial will show you how to use sklearn logisticregression class to solve binary classification problem to predict if a customer would buy a life insurance. At the end we have an interesting exercise for you to solve.
    Usually there are two types of machine learning problems (1) Linear regression where prediction value is continuous (2) Classification where predicted value is categorical. Logistic regression is used for classification problems mainly.
    #MachineLearning #PythonMachineLearning #MachineLearningTutorial #Python #PythonTutorial #PythonTraining #MachineLearningCource #LogisticRegression #sklearntutorials #scikitlearntutorials
    Code: github.com/codebasics/py/blob...
    Exercise: Open above notebook from github and go to the end.
    Exercise solution: github.com/codebasics/py/blob...
    Topics that are covered in this Video:
    0:00 - Theory (Explain difference between logic regression and classification)
    1:18 - What is logistic regression?
    1:26 - Classification types (Binary vs multiclass classification)
    1:53 - Explanation of logistic regression using the example of if person will buy insurance based on his age
    5:38 - Sigmoid or Logit function
    8:18 - Coding (for coding we are using an example of if a person will buy insurance or not based on his age)
    14:36 - sklearn predict_proba() function
    15:49 - Exercise (Solve a problem of predicting employee retention based on salary, distance to work, promotion, department etc)
    Do you want to learn technology from me? Check codebasics.io/ for my affordable video courses.
    Next Video:
    Machine Learning Tutorial Python - 8 Logistic Regression (Multiclass Classification): • Machine Learning Tutor...
    Populor Playlist:
    Data Science Full Course: • Data Science Full Cour...
    Data Science Project: • Machine Learning & Dat...
    Machine learning tutorials: • Machine Learning Tutor...
    Pandas: • Python Pandas Tutorial...
    matplotlib: • Matplotlib Tutorial 1 ...
    Python: • Why Should You Learn P...
    Jupyter Notebook: • What is Jupyter Notebo...
    Tools and Libraries:
    Scikit learn tutorials
    Sklearn tutorials
    Machine learning with scikit learn tutorials
    Machine learning with sklearn tutorials
    To download csv and code for all tutorials: go to github.com/codebasics/py, click on a green button to clone or download the entire repository and then go to relevant folder to get access to that specific file.
    🌎 My Website For Video Courses: codebasics.io/?...
    Need help building software or data analytics and AI solutions? My company www.atliq.com/ can help. Click on the Contact button on that website.
    #️⃣ Social Media #️⃣
    🔗 Discord: / discord
    📸 Dhaval's Personal Instagram: / dhavalsays
    📸 Codebasics Instagram: / codebasicshub
    🔊 Facebook: / codebasicshub
    📱 Twitter: / codebasicshub
    📝 Linkedin (Personal): / dhavalsays
    📝 Linkedin (Codebasics): / codebasics
    🔗 Patreon: www.patreon.com/codebasics?fa...

Komentáře • 604

  • @codebasics
    @codebasics  Před 2 lety +14

    To learn AI concepts in a simplified and practical manner check our course "AI for everyone": codebasics.io/courses/ai-for-everyone-your-first-step-towards-ai
    Do you want to learn technology from me? Check codebasics.io/ for my affordable video courses.

  • @interesting_vdos
    @interesting_vdos Před 2 lety +35

    I have never seen any other video explaining the concepts of machine learning so clearly. Keep up the great work..!!

  • @codebasics
    @codebasics  Před 4 lety +12

    Step by step roadmap to learn data science in 6 months: czcams.com/video/H4YcqULY1-Q/video.html
    How to learn coding for beginners | Learn coding for free: czcams.com/video/CptrlyD0LJ8/video.html
    5 FREE data science projects for your resume with code: czcams.com/video/957fQCm5aDo/video.html

    • @hanselsamuel
      @hanselsamuel Před 3 lety +2

      I really appreciate your tutorial videos, thank you. But how to find the "bought_insurance" values ?

  • @pamp3657
    @pamp3657 Před rokem +4

    One of the few videos that clearly shows the training data that the model is attempting to fit to. Thank you.

  • @MoreBalaji
    @MoreBalaji Před 2 lety +12

    Perfectly balanced video. It forces anyone to continue to watch other videos of this series. Very well explained in simple language. 👌

  • @ansh6848
    @ansh6848 Před 2 lety +4

    Best course you can get for learning ML is this only.
    Explanation is super awesome.
    Actually most of the books and courses shows you complex looking mathematical equations but this guy made all that easy for us.

  • @bhawin101283
    @bhawin101283 Před 5 lety +99

    Perfect explanation with proper examples. Great job.

    • @anand.prasad502
      @anand.prasad502 Před 4 lety +1

      medium.com/trainyourbrain/would-you-read-this-article-or-not-b757d0e26cf8

  • @mehmetkaya4330
    @mehmetkaya4330 Před 5 lety +10

    Thank you again! Great explanation! Always great tutorials!

  • @sidduhedaginal
    @sidduhedaginal Před 4 lety +16

    Finally i got perfect trainer for ML, your skills are excellence sir, we are very proud of you sir.

    • @codebasics
      @codebasics  Před 4 lety +3

      Glad you liked it :)

    • @matinpathan5186
      @matinpathan5186 Před 3 lety +1

      Yes is good but if you like his tutorials then tell your friend to subscribe his channel and hit the like button... that we can do from our side

  • @codebasics
    @codebasics  Před 4 lety

    Solution link for the exercise: github.com/codebasics/py/blob/master/ML/7_logistic_reg/Exercise/7_logistic_regression_exercise.ipynb
    Step by step guide on how to learn data science for free: czcams.com/video/Vn_mmOuQkSA/video.html
    Machine learning tutorials with exercises:
    czcams.com/video/gmvvaobm7eQ/video.html

  • @Sarah-st7jp
    @Sarah-st7jp Před 2 lety +26

    Sir, I know so surely that I can bank on your data science and python videos when I need to gain an in-depth understanding. Your content gives me the hope and clarity that I needed. God bless you and your undying passion to make such useful content for us. Thank you so much for all your hard-work sir!!! :)

  • @shivangitomar5557
    @shivangitomar5557 Před 4 lety +10

    You are the best teacher! I love the exercises at the end of each topic, which strengthens our understanding of what we learnt!!! Thank you so much! :)

  • @abhishekdobliyal7178
    @abhishekdobliyal7178 Před 3 lety +6

    Thank You Sir, I have learned a lot from your vids :). I was really perplexed by Logistic Regression and I am glad
    CZcams recommended this to me :)

  • @zestful14
    @zestful14 Před 4 lety +1

    This video is fantastic. I'm teaching myself machine learning and this was one of the most helpful resources I've found online. Excited to watch/work-through the rest of the videos! Thank you so much

    • @anand.prasad502
      @anand.prasad502 Před 4 lety

      medium.com/trainyourbrain/would-you-read-this-article-or-not-b757d0e26cf8

  • @fahadreda3060
    @fahadreda3060 Před 5 lety +4

    Another Great Tutorial, Thank you sir, Waiting for the next tutorial, keep up the good work

  • @nguyentuanhung3858
    @nguyentuanhung3858 Před 6 měsíci

    Started learning machine learning on your youtube.
    Absolute Masterclass , you are my real teacher sir!!!

  • @shreyasb.s3819
    @shreyasb.s3819 Před rokem

    I never seen anyone explaining simple as like this.
    Others making complicated like maths intuition.
    Thanks code basics

  • @GeorgeTrialonis
    @GeorgeTrialonis Před 4 lety +6

    Thank you very much for the videos on ML, AI, Python, etc. They help me learn a lot. Your explanations are clear and well understood. Thanks.

  • @zerostudy7508
    @zerostudy7508 Před 5 lety +3

    i'm Not afraid to learn things with complicated term anymore! this teacher is the best at explanation.

    • @zerostudy7508
      @zerostudy7508 Před 5 lety

      @@codebasics You are good at it. I thank you.

  • @flyingsalmon
    @flyingsalmon Před 2 lety +4

    I love your tutorials. They're perfectly paced, with right amount of context and explanation, great examples, and patient but efficient delivery. I hope you continue to produce more. Subscribed here and also Liked all of the videos I've found so far from you. Best.

  • @user-ee6nk8sc3t
    @user-ee6nk8sc3t Před 24 dny

    You make people feel so welcomed to data field with your teaching skills. You are always the best.

  • @Hari983
    @Hari983 Před 2 lety

    Very well done and explained even for beginners - thank you so much!

  • @PollyMwangi-cp3jn
    @PollyMwangi-cp3jn Před 3 měsíci +2

    Actually, I fine tuned my model and was able to achieve an accuracy of 1.0. Thankyou so much sir. This might just be the best channel I have seen.🥳

    • @kibs_neville
      @kibs_neville Před 3 měsíci +2

      Hi, I have some slight problem. How can I plot the prediction curve after training my model? Would be glad if you reply. Thanks

    • @anishagarwal71
      @anishagarwal71 Před 23 dny

      Could you pls tell me what exactly did you do to fine tune it?

  • @mponcardas94
    @mponcardas94 Před 5 lety +7

    I love your series of videos as you are concerned with the student's learning! Thanks!

  • @pagnonig
    @pagnonig Před 4 lety +1

    Your videos are awesome. I'm learning so much!

  • @bandhammanikanta1664
    @bandhammanikanta1664 Před 4 lety

    Perfect explanation on logistic regression.
    Loved it. Thanks a lot.

    • @anand.prasad502
      @anand.prasad502 Před 4 lety

      medium.com/trainyourbrain/would-you-read-this-article-or-not-b757d0e26cf8

  • @prakritreeeeeee
    @prakritreeeeeee Před rokem

    Thank you so much for the graphical explanation...the concepts are crystal clear in my mind now.

  • @barakatosalon
    @barakatosalon Před 5 lety +1

    Great Class, you are the best of the best !!!

  • @riyamitra8901
    @riyamitra8901 Před 2 lety +2

    For the first time after so many courses, videos, whitepapers, github, kaggle, exercises, wiki pages I am genuinely enjoying Machine Learning and I am doing all the coding and exercises by myself obviously after learning and understanding it all. Thanks a lot!!!

    • @codebasics
      @codebasics  Před 2 lety +1

      Glad you like them Riya and I wish you all the best! I have many playlists and recently left my job to focus on online teaching. My goal is to produce even a better quality tutorials then this.

    • @riyamitra8901
      @riyamitra8901 Před 2 lety

      @@codebasics I am trying to follow all of your videos to improve in my career. I am trying to get a job with a clear concept.

    • @riyamitra8901
      @riyamitra8901 Před 2 lety +1

      @@codebasics One question here. Why we did not remove one of the dummy variable after dropping salary column in Logistic regression like we did for Linear?

    • @09_samarpanbasu7
      @09_samarpanbasu7 Před rokem

      @@riyamitra8901 I think ...as logistic regression can handle multicollinearity between the dummy variables so it's not necessary to drop the last col.

  • @MultiSpiros123
    @MultiSpiros123 Před 5 lety +2

    Thanks one of the best tutorials !

  • @khalidhasan1793
    @khalidhasan1793 Před rokem

    I paused the video and commented, it's an excellent series that begins with ML.

  • @adishvakharia3559
    @adishvakharia3559 Před 4 lety

    Detailed and really helpful. Thank you.

  • @sunnyveerpratapsingh1102
    @sunnyveerpratapsingh1102 Před 4 lety +3

    bro you are best .. tried to swirl thru other online videos and then I end up watching your videos and I understand better .

    • @codebasics
      @codebasics  Před 4 lety +1

      Sunnny Singh, I am happy this was helpful to you

    • @rutvikkumbhar6736
      @rutvikkumbhar6736 Před 10 měsíci

      Any update you can give how's your data science journey is going as I am aspiring to be a data scientist..

  • @phaniauce
    @phaniauce Před 4 lety

    Awesome explanation. I like this practical math and algorithmic explanation.

  • @ridael-mehdawe4681
    @ridael-mehdawe4681 Před 4 lety

    among several videos, this one is the best. appreciated

  • @mario1ua
    @mario1ua Před 7 měsíci +1

    Great explanation, I've understood everything, thanks!

  • @imaansarwar2314
    @imaansarwar2314 Před 2 lety

    thank you so much ! you have helped alot in learning the algorithms. Saved time with such a quick and easy way of explaining as I didn't have time for my fyp compleion and these videos are saving my time to get an idea of all algorihtms

  • @abdulmuzakir
    @abdulmuzakir Před 3 lety +1

    Thanks, sir .. your explanation is really clear and so easy to understand 👍🏼

  • @VyNguyen-xy3il
    @VyNguyen-xy3il Před rokem

    Sir, I extremely appreciate your videos and efforts in teaching these things. Very helpful and great explanation!!

  • @pratikghute2343
    @pratikghute2343 Před rokem

    I have no other words to say, the comments done by others have already conveyed my message to you!, Lots of love and thank you !

  • @guneyfatma
    @guneyfatma Před 8 měsíci +1

    Thnaks a lot for theese amazing contents. I have just discovered your videos!

  • @tariqahassan5692
    @tariqahassan5692 Před měsícem

    it is one of the fantastic videos about Logistic Regression .. Many thanks

  • @Sparshchokra
    @Sparshchokra Před 5 lety

    Hi, i found your course is truly enhancing the path towards Machine Learning concepts, kindly continue this and sir achieve a complete set of this machine learning course including all the kick start algorithms.
    Thanks
    Sparsh

    • @codebasics
      @codebasics  Před 5 lety +1

      Thanks for appreciation Sparsh. I am continuing the series, it is just that due to my schedule I am not finding lot of time to work on it but I will try my best to speed up new tutorial additions.

  • @siddhantkaushik4606
    @siddhantkaushik4606 Před 3 lety

    amazing.
    astounding.
    bewildering.
    breathtaking.
    extraordinary.
    impressive.
    marvelous.
    miraculous.
    even all these adjectives are less to tell the quality of the video.
    Thanks a million.

    • @codebasics
      @codebasics  Před 3 lety

      ha ha .. nice. you made my day with this shower of praise Siddhant. Thank you for your kind words :)

  • @mapa5000
    @mapa5000 Před rokem

    Thank you very much ! Your videos are always my best choice to learn ML

  • @noorameera26
    @noorameera26 Před 3 lety +1

    This video is really really good. Love the way you teach, your pacing and all the things you mentioned are really useful. Thank u and may god bless u!

  • @chrismagee5845
    @chrismagee5845 Před rokem

    Exactly what I was looking for, Thank You!

  • @micro_Dots
    @micro_Dots Před 2 lety

    clearly understandable explanation.
    Thank you so much.

  • @0xN1nja
    @0xN1nja Před 2 lety

    one of the best explanation I've ever seen

  • @piyushjha8888
    @piyushjha8888 Před 4 lety +3

    78 percent accuracy. I do all your exercises but in this I learned a lot. Thank you sir for such a great series @codebasics

    • @kalaipradeep2753
      @kalaipradeep2753 Před 9 měsíci

      Hi bro....

    • @kalaipradeep2753
      @kalaipradeep2753 Před 9 měsíci

      Now I learn machine learning....
      Now What are you doing. I mean study or work

    • @piyushjha8888
      @piyushjha8888 Před 9 měsíci +1

      I work in a bank as a software engineer. This channel is a gem as this explains the ML concept in laymen terms. I was able to give most of the answers related to ML because of codebasics and deep learning Andrew Ng course

  • @linujose2536
    @linujose2536 Před 5 lety +2

    amazing tutorial!

  • @pallabsaha4098
    @pallabsaha4098 Před 5 lety +6

    thank you sir for your video.

  • @nilupulperera
    @nilupulperera Před 4 lety

    Dear Sir
    What a beautiful datasheet you have provided for practice with this video.
    Spent more than two days to play with it.
    Playing with the datasheet opened another dimension of the learning curve.
    Thank you very much for providing relevant exercises like this as a challenge!

    • @codebasics
      @codebasics  Před 4 lety +1

      Happy that this is helping you Nilupul.

  • @Christian-mn8dh
    @Christian-mn8dh Před 5 lety +4

    just subscribed, your very good at explaining. thank you!

  • @adityabikramarandhara9477

    Thanks a lot for the lucid explanation.
    In the exercise, I got an accuracy of 77.2% in my model prediction.

    • @kalaipradeep2753
      @kalaipradeep2753 Před 9 měsíci

      Hi bro...
      Now I learn machine learning...
      What are you doing.... I mean study or work

  • @zaidzeee
    @zaidzeee Před 4 lety

    this video really really very helpful.
    thank you so much for this amazing kwnldge
    please make more video request.

  • @shuaibalghazali3405
    @shuaibalghazali3405 Před 7 měsíci

    Thanks a lot for this i was able to implement logistic regression after so many tutorials

  • @paramjeetgill1558
    @paramjeetgill1558 Před 5 lety

    Very nice and you present easiest way to understand. Thank you

  • @danielnderitu5886
    @danielnderitu5886 Před 2 lety

    I like your tutorials very much, the explanation therein is superb and makes one understand even very hard to grasp concepts.

  • @manusingh9007
    @manusingh9007 Před 4 lety +1

    On first attempt, i considered 'left' as dependent variable and everything else including salary and department as independent variable, got 77% score of accuracy. Thanks for the wonderful video.

    • @codebasics
      @codebasics  Před 4 lety

      Great job manu. its a good score. Video description has a solution link, you can verify your code with mine.

  • @sundayagu2078
    @sundayagu2078 Před 2 lety

    God bless you and may He provide angles to solve all your problems. Thank you

  • @codinghighlightswithsadra7343

    Thanks a bunch, Subscribed here and also Liked all of the videos I've found so far from you. Best.

  • @kibs_neville
    @kibs_neville Před 3 měsíci

    Well explained, Thanks!

  • @amanullahmahabub78
    @amanullahmahabub78 Před 4 lety

    You guys are life savers. man love your videos.

    • @codebasics
      @codebasics  Před 4 lety

      Amanullah, I am happy it helped you :)

  • @linusolmin9313
    @linusolmin9313 Před 18 dny

    Thank you! So well done

  • @jugabrat6797
    @jugabrat6797 Před 8 měsíci

    Your way of teaching is very good. Thanks for the video ❤❤❤

  • @laxpanwar11
    @laxpanwar11 Před 3 hodinami

    Thanks. It is really informative.

  • @michaelpeel3716
    @michaelpeel3716 Před 2 lety +1

    Many thanks this is the first explanation that provides context and examples making its so simple to understand.

    • @codebasics
      @codebasics  Před 2 lety

      Glad you liked it Michael

    • @engihabit
      @engihabit Před 2 lety

      @@codebasics 15:35 I can’t execute it??
      model.predict(57) and any number like 25, 60 got the following ValueError: Expected 2D array, got 1D array instead:
      array=[57].

  • @asamadawais
    @asamadawais Před 2 lety

    Dhavel you are excellent in explaining difficult concepts in very simple language!

    • @codebasics
      @codebasics  Před 2 lety +1

      I am happy this was helpful to you.

  • @roshangeorge97
    @roshangeorge97 Před rokem

    thank you for the content, helped me a lot!

  • @tayfundogruer8026
    @tayfundogruer8026 Před 9 měsíci

    Bro it was easy and clean. Thanks!

  • @boughrood
    @boughrood Před 9 měsíci

    Very interesting and useful - well presented too

  • @aidaash8600
    @aidaash8600 Před rokem

    it was amazing. thank you so much

  • @shylashreedev2685
    @shylashreedev2685 Před 2 lety

    Thank u so much..it really helped to clear my concepts

  • @saranyachimirala8351
    @saranyachimirala8351 Před 3 lety +2

    This video had good information, it was really helpful. I am still a learner, new to this field. I understand how to write and basics of confusion matrix using binary classification. But some terminologies are confusing. Can you please explain what exactly are base rate, test incidence, conditional incidence, classification incidence? That would be appreciated.

  • @SandeepYadav-pm8yc
    @SandeepYadav-pm8yc Před 4 lety +3

    Finally got the Python version of Andrew Ag's machine learning course. With a better explanation.
    thanks.

  • @narsinhakulkarni9167
    @narsinhakulkarni9167 Před 5 lety

    Sir .....I cannot thank you enough!!!......thanks for introducing kaggle as well.

  • @amandaahringer7466
    @amandaahringer7466 Před 2 lety

    Very helpful!

  • @leooel4650
    @leooel4650 Před 5 lety +8

    Awesome as always, thanks for everything!
    i got a 77% model accuracy based on the satisfaction_level

    • @jsbean8415
      @jsbean8415 Před 4 lety

      How did you get the prediction model accuracy by depedent variable? And 77% meaning is the probability that they will leave the company?

    • @nxbil2397
      @nxbil2397 Před 4 lety

      @@jsbean8415 model.score()

    • @jsbean8415
      @jsbean8415 Před 4 lety

      @@nxbil2397 that will show you the overal accuracy of your model. My question is , how you will get the probablity % that the employee will leave given the dependent variables? Like the one you have mentioned "satisfaction level".

  • @shreyaasthana7313
    @shreyaasthana7313 Před 8 měsíci

    Sir I tried this method, it is very easy to understand and use.. thank you sir

  •  Před 2 lety +1

    Perfect explanation!

  • @aurorasart9458
    @aurorasart9458 Před 2 lety

    Thank you very much! Very nice video and perfectly explained!!

  • @dantedt3931
    @dantedt3931 Před 5 lety

    Thank you very much!

  • @alienwareCL
    @alienwareCL Před 7 měsíci

    Very well explained, thanks!

  • @user-jh4wo6ok4s
    @user-jh4wo6ok4s Před 18 dny

    Thank you so much, sir. I've got the score in the exercise 0.797. 🙂

  • @bhavyanaik74
    @bhavyanaik74 Před 3 lety

    Thank you so much....very good explanation

  • @akhtarshaikh5594
    @akhtarshaikh5594 Před 5 lety +1

    excellent explanation...thanks lot.. please make video on deep learning model using tensorflow and caffe...

  • @bestineouya5716
    @bestineouya5716 Před 4 lety

    Actually you are the best explainer

  • @devanshgoel9070
    @devanshgoel9070 Před 2 lety

    Thank you sir for this amazing explanation of Logistic Regression.

  • @SohelRana-eq4ib
    @SohelRana-eq4ib Před 2 lety

    You are the best teacher

  • @DataThinkers
    @DataThinkers Před 5 lety +2

    Nice Sir, try to create SVM or PCA next with some mathematical explanation. thank you

  • @vinitasharma5025
    @vinitasharma5025 Před 2 lety

    very useful video.... you explain everything in a very simple manner. Thank you

  • @vinayaksharma7134
    @vinayaksharma7134 Před rokem

    Thanks a lot Sir!!

  • @shivatarun9125
    @shivatarun9125 Před 5 lety +2

    awesome.... :) Sir, could you please make a video on how to detect and handle/dealing with outliers in model..? eagerly awaiting from you, haven't got any clarity on outliers.

  • @anjanisuman6428
    @anjanisuman6428 Před 5 lety

    Awesome tutorial

  • @HearterSG
    @HearterSG Před 5 lety +1

    great again! looking forward to your future videos!

  • @krishkonnect814
    @krishkonnect814 Před 4 lety +1

    Thankyou very much for all help and support. Can you please make a video on mathematical explanation of sigmoid and logit function also ?

  • @gusinthecloud
    @gusinthecloud Před 2 lety

    The best explanation as always

  • @nsbeastgaming
    @nsbeastgaming Před 3 lety

    nice explanation ever sir .

  • @adilmuhammad6078
    @adilmuhammad6078 Před rokem

    Wow this is so good