KNN Classification & Regression in Python

Поделиться
HTML-код
  • Опубликовано: 7 сен 2024
  • #knn #machinelearning #python
    In this video, I've explained the concept of KNN algorithm in great detail. I've also shown how you can implement KNN from scratch in python.
    For more videos please subscribe -
    bit.ly/normaliz...
    Support me if you can ❤️
    www.paypal.com...
    www.buymeacoff...
    Source code -
    github.com/Suj...
    ML algorithms from scratch -
    • ML Algorithms Clearly ...
    Facebook page -
    / nerdywits

Комментарии • 39

  • @chinmayrath8494
    @chinmayrath8494 Год назад +2

    your channel is a blessing to us students! thank you and keep em coming!

  • @DaardieAnderMan
    @DaardieAnderMan 3 года назад +2

    Outstanding! I once heard that a persons intellect correlates with his/her ability to explain it in a simple enough matter that someone with no experience or prior knowledge will understand it. So Sir, your must be a genius! I'm doing a project in machine learning, and this is the single greatest explanation of the entire KNN concept. Thank you very much.

    • @NormalizedNerd
      @NormalizedNerd  3 года назад

      Loved your words...Best of luck for your project.

  • @terryterry3733
    @terryterry3733 2 года назад

    Super bro nice explanation and one thing i want to understand HOW KNN GETS OVERFIT?

  • @productionnet2242
    @productionnet2242 3 года назад +2

    Hi. Great Video. But I got lost in 10:04, you start explaining that in one dimension the search space in 0.004, considering k=4 and an expected split of 1/1000 among data. Then when you moved to 2 dimensions I dont get why you keep the value of 0.004 for the area of the rectangle. I mean if I placed the new observation in the middle of the square then the radius of the corresponding circle would be 0.00285, matching it with the diagonal of the outter square required to 2 point on each side of the diagonal. Could you explain me this.

  • @HasanNaser01
    @HasanNaser01 3 года назад +1

    Nice explanation, thanks to share

  • @mdmynuddin1888
    @mdmynuddin1888 3 года назад

    sound is just awesome.Super Bommmmm

  • @antoinegar.638
    @antoinegar.638 Год назад

    Amazing content thank you sir !

  • @kat-bn3nw
    @kat-bn3nw 3 года назад

    Thank you so much for this video. In case i want to predict the univariate time series with 2 variables t:time and x:value at time t. Would you mind to give me some advice about how to do it?

  • @spearchew
    @spearchew 3 года назад

    great video, very useful.
    I am not entirely sure your "dist = np..." line is doing what you hope it is doing. It is NOT outputting a single distance value, as far as I can see.
    np.sqrt(np.square(X_train[i]-new_x_sample).sum(axis=1))
    something more along these lines you might like to try

    • @NormalizedNerd
      @NormalizedNerd  3 года назад

      Please run the code. It should output a single value.

    • @spearchew
      @spearchew 3 года назад

      @@NormalizedNerd Yes apologies. I'm not sure what happened in my code to lead me to the conclusion above.
      Sure enough the following outputs single distance values:
      arr1 = np.array([[0.73654, 0.321242], [0.33654, 0.121242], [0.93654, 0.121242]])
      arr2 = np.array([0.23253, 0.545423])
      for i in range(len(arr1)):
      dist = np.sqrt(sum(np.square(arr1[i]-arr2)))
      print(dist)
      Thanks again for a great video

    • @spearchew
      @spearchew 3 года назад

      Sorry to keep going on about this... The following screenshot shows why it is I am feeling a bit confused here. I can't see my mistake but I must have made an error somewhere
      i.imgur.com/0XWbRSj.jpg

    • @NormalizedNerd
      @NormalizedNerd  3 года назад

      @@spearchew I guess it's a problem related to dimensions. Print the dimensions of everything that you are accessing inside the loop.

    • @spearchew
      @spearchew 3 года назад

      @@NormalizedNerd I think you're quite right. Even though my "sample data" contains only ONE row of data, when I call the function it seems I am still required to specifically refer to the first element: sample_data[0] in order for the loop to produce a single distance measure.
      Sometimes the behaviour of Python is surprising to me, as in this case - thanks for your feedback and for the code which has been an excellent education.

  • @Lol-xu2np
    @Lol-xu2np 2 года назад

    Can you please tell what happens when there are 2 green and 2 red classes for a new data in knn classification algorithm?

    • @prasadkakade1529
      @prasadkakade1529 2 года назад +1

      You should never select a k value which will be even. Select k value which will be odd like 3,5,7.

  • @davidc.4612
    @davidc.4612 3 года назад

    Thank you very much it was very helpful. Continue the hard wok :)

  • @dewipuspita3783
    @dewipuspita3783 3 года назад

    Easy to learn 👍🏻

  • @michaelpham6952
    @michaelpham6952 4 года назад

    Awesome video!! Can you please to a video on using KNN for a high dimensional database?

    • @NormalizedNerd
      @NormalizedNerd  4 года назад +1

      I think sklearn should be used for higher dimensional data.

    • @michaelpham6952
      @michaelpham6952 4 года назад +1

      @@NormalizedNerd I'm not really familiar in this field of study but in my current project, we have to use KNN for a database that has the dimension of 520 columns, I have heard of preprocessing approaches to reduce the dimensions of the database like by removing the less "important" features but I'm not really sure how KNN is used in this scenario, do you have any suggestion?

    • @NormalizedNerd
      @NormalizedNerd  4 года назад +1

      The trick is to reduce the number of features using PCA or (and) tSNE. Then you can apply KNN. As a rule of thumb, you should reduce the dimension below 50.

  • @mandarjoshi6814
    @mandarjoshi6814 4 года назад +1

    Can you please do KMeans next?

    • @NormalizedNerd
      @NormalizedNerd  4 года назад +1

      Suggestion noted!

    • @NormalizedNerd
      @NormalizedNerd  4 года назад +1

      Check out my new video on K-means...
      ruclips.net/video/IB9WfafBmjk/видео.html

    • @ramakanthrama8578
      @ramakanthrama8578 4 года назад

      @@NormalizedNerd Hey !!! Can you please do a video on GBDT or XGBoost ?
      Thanks !!

  • @maartjedejong3398
    @maartjedejong3398 4 года назад

    Good music haha

  • @abdarker
    @abdarker 4 года назад +1

    lmaooooooo