Logistic Regression in Python from Scratch | Simply Explained

Поділитися
Вставка
  • Опубліковано 3 лют 2021
  • 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

КОМЕНТАРІ • 83

  • @CodingLane
    @CodingLane  2 роки тому +6

    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.

  • @saumyashah6622
    @saumyashah6622 3 роки тому +11

    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 :)

    • @CodingLane
      @CodingLane  3 роки тому +1

      Thank you so much for such a good compliment 😊

  • @justtimepass2948
    @justtimepass2948 Рік тому +1

    Please don't stop uploading videos it's really really superb explanation in a precise manner. Great job keep it up bro 😎

  • @pavithranpavithran7354
    @pavithranpavithran7354 5 місяців тому +2

    Man for the past 2 days i have been searching the explanation
    Man you rocked it .Keep going brother

  • @MeetPatel-sk7pu
    @MeetPatel-sk7pu 3 роки тому +5

    I don't have words for give compliment for your explanation bro.
    MOST CLEAR EXPLANATION I EVER SEEN BEFORE. 🍺🥂

    • @CodingLane
      @CodingLane  3 роки тому +2

      And I don’t have words to appreciate your comment ! Thank you very much ! It really means alot to me

  • @AmanTheDisciple
    @AmanTheDisciple 2 роки тому +1

    A very good video, been searching for something like this for so long. Finally found it. Thanks bro.

  • @avinashdubey1482
    @avinashdubey1482 2 роки тому +1

    I was searching a lot and finally bro!!! I got you!!!!! thanks a lot

    • @CodingLane
      @CodingLane  2 роки тому

      Thank you so much! This means a lot to me.

  • @ipapergrey6654
    @ipapergrey6654 4 місяці тому

    Thank you so much you really helped me start my ML journey

  • @jasurtoshpolatov9153
    @jasurtoshpolatov9153 Рік тому +1

    500th like by me, good luck👍

  • @priyankagarg8999
    @priyankagarg8999 2 роки тому

    Thanks for sharing these videos😀. Your all videos are informative and make it so simple for me to understand the concept🤓.

    • @CodingLane
      @CodingLane  Рік тому

      It's my pleasure. Happy to hear that! 🙂

  • @ridwanridlonugroho9849
    @ridwanridlonugroho9849 Рік тому

    thanks, very good video 👍

  • @brindhasenthilkumar7871
    @brindhasenthilkumar7871 3 роки тому +1

    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

    • @CodingLane
      @CodingLane  3 роки тому

      Thank you so much ! I am elated after reading this. I am glad you find my videos helpful.

    • @brindhasenthilkumar7871
      @brindhasenthilkumar7871 3 роки тому +1

      @@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

    • @CodingLane
      @CodingLane  3 роки тому

      Sure ! Thanks @@brindhasenthilkumar7871

  • @gratusrichard535
    @gratusrichard535 Рік тому +1

    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 :)

    • @CodingLane
      @CodingLane  Рік тому

      Thanks a lot for the compliment 😇. Means a lot. Currently, I don’t have any paid courses, hoping to make them in future!

  • @larrysummer2015
    @larrysummer2015 3 роки тому +1

    keep it up man... you couldn't be better teaching...

  • @sauravsharma690
    @sauravsharma690 3 роки тому +2

    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.

    • @CodingLane
      @CodingLane  3 роки тому

      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.

  • @IbrahimAli-kx9kp
    @IbrahimAli-kx9kp 2 роки тому +3

    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 😄

    • @CodingLane
      @CodingLane  2 роки тому +2

      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 😇

  • @mdtufajjalhossain1246
    @mdtufajjalhossain1246 3 роки тому +1

    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.

    • @CodingLane
      @CodingLane  3 роки тому

      Thank you so much! And yea... I will try to make that video too

  • @-alfeim2919
    @-alfeim2919 Рік тому +1

    Amazing job!

  • @ShivamSharma-eh8vb
    @ShivamSharma-eh8vb Рік тому +1

    you are awsome

  • @adrenochromeaddict4232
    @adrenochromeaddict4232 8 місяців тому

    you just saved my life mate thx

  • @003kazimehrabrashid4
    @003kazimehrabrashid4 Рік тому

    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

  • @babaabba9348
    @babaabba9348 3 роки тому +1

    very informative, you are the best continue

    • @CodingLane
      @CodingLane  3 роки тому

      Thank You so much 😇 !!

    • @babaabba9348
      @babaabba9348 3 роки тому

      @@CodingLane
      i have a question that concerns boudary and logistic regression how can i contact you in person

    • @CodingLane
      @CodingLane  3 роки тому

      @@babaabba9348 mail me on codeboosterjp@gmail.com

    • @babaabba9348
      @babaabba9348 3 роки тому

      @@CodingLane
      thank you so much mate

    • @babaabba9348
      @babaabba9348 3 роки тому +1

      @@CodingLane
      maybe it would be better that you delete your address

  • @anuradhashukla6059
    @anuradhashukla6059 2 роки тому +1

    it was really helpful

  • @jagajaga6908
    @jagajaga6908 Рік тому +1

    bro thank you for good video

  • @proterotype
    @proterotype 3 роки тому +1

    Great video. You made it seem easy. And Easy is good. Thanks a lot

    • @CodingLane
      @CodingLane  3 роки тому

      Thank you so much ! I really appreciate it

  • @soujanyapm480
    @soujanyapm480 2 роки тому +1

    Thanks for this video, it was very informative.
    Could you please explain the formula you have used for accuracy in accuracy function?

    • @CodingLane
      @CodingLane  2 роки тому

      Hi… I calculated error rate… which is % of wrong predictions and then subtracted it from 100

  • @nhs881
    @nhs881 2 роки тому +1

    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?

    • @CodingLane
      @CodingLane  2 роки тому

      For this you can learn numpy and pandas from any video tutorial. That will help you in all these sorts of data preprocessing.

  • @dinmadaniel9830
    @dinmadaniel9830 Рік тому

    in your cost where did you get y and from cause you never defined them

  • @mukeshgupta9806
    @mukeshgupta9806 Місяць тому

    By implementing the same code it is showing an error: weight is not defined what should I do

  • @nauman_26
    @nauman_26 2 роки тому +1

    Thank you for this video, it is really helpful.
    Can you make a video on feature scaling from scratch?

    • @CodingLane
      @CodingLane  2 роки тому +2

      Thanks for the suggestion… i will see if i can make a video on it

    • @nauman_26
      @nauman_26 2 роки тому +1

      @@CodingLane Thank you for your support

  • @philtoa334
    @philtoa334 Рік тому +1

    Very Nice.

  • @taruchitgoyal3735
    @taruchitgoyal3735 3 роки тому +1

    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?

    • @CodingLane
      @CodingLane  3 роки тому +1

      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!

  • @ajinkyajagtap5151
    @ajinkyajagtap5151 2 роки тому

    how to plot logistic regression ?

  • @RajivKumar-nv2gj
    @RajivKumar-nv2gj 3 роки тому +1

    Thanks bro

  • @acno_randintrandint4182
    @acno_randintrandint4182 3 роки тому +1

    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

    • @CodingLane
      @CodingLane  3 роки тому +2

      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

    • @CodingLane
      @CodingLane  3 роки тому +1

      Hope I made it clear now.

    • @acno_randintrandint4182
      @acno_randintrandint4182 3 роки тому

      @@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

    • @acno_randintrandint4182
      @acno_randintrandint4182 3 роки тому

      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

    • @acno_randintrandint4182
      @acno_randintrandint4182 3 роки тому

      np.mean(P == y_test)

  • @kalidasabuj8940
    @kalidasabuj8940 Рік тому +1

    Please make more videos on ml algorithms

    • @CodingLane
      @CodingLane  Рік тому +1

      Thanks for the suggestion. Will also make videos on other ML algorithms. Though it might take some time.

  • @vg5675
    @vg5675 Місяць тому

    how to select best features to get the highest possible f1 score

  • @theopensparrow3274
    @theopensparrow3274 2 роки тому +1

    Content is very good, but the presentation is not satisfactory.

    • @CodingLane
      @CodingLane  2 роки тому

      Thank you for your feedback. I have tried to improve the presentation style in the newer videos. I hope you find it better.

  • @glenmason6680
    @glenmason6680 3 роки тому +1

    sorry mate you need to slow down a bit

  • @danish5326
    @danish5326 3 роки тому +1

    I love your explanation but please don't fake your accent. Its quite annoying.

    • @CodingLane
      @CodingLane  3 роки тому

      Thank You Danish !

    • @kian0902
      @kian0902 Рік тому

      What do you mean by ''Fake your accent'' ?