Coding Challenge #70: Nearest Neighbors Recommendation Engine - Part 2

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 มิ.ย. 2024
  • In this multi-part coding challenge, I create a movie recommendation engine using the "nearest neighbor" algorithm. Code: thecodingtrain.com/challenges...
    p5.js Web Editor Sketches:
    🕹️ Nearest Neighbors, Part 1: editor.p5js.org/codingtrain/s...
    🕹️ Nearest Neighbors, Part 2: editor.p5js.org/codingtrain/s...
    🕹️ Nearest Neighbors, Part 3: editor.p5js.org/codingtrain/s...
    🕹️ Nearest Neighbors, Part 3 with added styling: editor.p5js.org/codingtrain/s...
    Other Parts of this Challenge:
    📺 Nearest Neighbors Recommendation Engine - Part 1: • Coding Challenge #70: ...
    📺 Nearest Neighbors Recommendation Engine - Part 3: • Coding Challenge #70: ...
    🎥 Previous video: • Coding Challenge #69: ...
    🎥 Next video: • Coding Challenge #71: ...
    🎥 All videos: • Coding Challenges
    References:
    📕 The Nature of Code Part 2 (Spring 2017) - Intelligence and Learning: github.com/shiffman/NOC-S17-2...
    📓 Notes on Pearson's correlation coefficient: github.com/shiffman/NOC-S17-2...
    Videos:
    🚂 My Video on Associative Arrays: • 5.2: Associative Array...
    🔴 Coding Train Live 91: • Live Stream #91: Sessi...
    Related Coding Challenges:
    🚂 #98 Quadtree: • Coding Challenge #98.1...
    🚂 #104 Linear Regression with TensorFlow.js: • Coding Challenge #104:...
    🚂 #105 Polynomial Regression with TensorFlow.js: • Coding Challenge #105:...
    Timestamps:
    0:00 Introduction
    1:01 euclideanDistance()
    1:44 Similarity score
    1:58 NearestNeighbors()
    2:51 Check similarity scores
    6:28 Sort the users
    10:29 Put similarity score in an object
    14:03 Display top five similarity scores
    16:00 Reset resultP
    Editing by Mathieu Blanchette
    Animations by Jason Heglund
    Music from Epidemic Sound
    🚂 Website: thecodingtrain.com/
    👾 Share Your Creation! thecodingtrain.com/guides/pas...
    🚩 Suggest Topics: github.com/CodingTrain/Sugges...
    💡 GitHub: github.com/CodingTrain
    💬 Discord: thecodingtrain.com/discord
    💖 Membership: th-cam.com/users/thecodingtrainjoin
    🛒 Store: standard.tv/codingtrain
    🖋️ Twitter: / thecodingtrain
    📸 Instagram: / the.coding.train
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 p5.js Web Editor: editor.p5js.org/
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...
    This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
    #nearestneighbors #similarityscore #euclideandistance #associativearrays #p5js #javascript

ความคิดเห็น • 36

  • @micahwaring8224
    @micahwaring8224 7 ปีที่แล้ว +15

    I like that you put the next part in the description.

  • @robn2497
    @robn2497 5 ปีที่แล้ว +3

    Dude the last video was awesome. You connected euclidean distance math to data set. Introduced a weakness to the method and Provided Solution. This is like practical math making math more intuitive and relatable. The context of the programming makes the math so easy to digest. Thanks.

  • @mightyleguan1451
    @mightyleguan1451 7 ปีที่แล้ว +3

    13:18 I have never seen Dan like this before. It's ok, we all make mistakes :)
    I also think it's awesome that you didn't cut this out.
    Have a nice day!

  • @JeremyStover
    @JeremyStover ปีที่แล้ว +1

    5 years too late, but if you use Union Finds then euclidean distance on the results of that, you can have a fully dynamic recommendation engine.

  • @geoffwagner4935
    @geoffwagner4935 9 หลายเดือนก่อน

    i actually did wake up this mourning and wish this, thankfully i do , it's still here, Dan exists, his channel exits, life exist sun is out tho i mostly hide from it and cover the windows

  • @alengm
    @alengm 7 ปีที่แล้ว +1

    Can you make a video where you just trigger all the sounds you have(ding, thisdot, dundun...) preferably in form of a music?
    Maybe write an algorithm that can imitate music with given sounds.

  • @SirCutRy
    @SirCutRy 7 ปีที่แล้ว

    You could sort the names by their similarity score, at least in Python:
    def k_nearest(k, names, scores):
    return names.sort(lambda x: scores[names.index(x)])[::-1][:k]

  • @ysoseriousbro4254
    @ysoseriousbro4254 3 ปีที่แล้ว

    If you have thousands and thousands of people's preferences, since we are calculating a "distance" couldn't we think of plotting people in an n dimensional space based on the number of movies and their ratings and then use a quadtree to more quickly get our nearest neighbors? This would probably be more useful if we wanted to group everyone since we would have to have nested loops, but just a thought.

  • @geoffwagner4935
    @geoffwagner4935 9 หลายเดือนก่อน

    *as lightning strikes and half of California loses power overnight*

  • @CAMILOLcamiLOL
    @CAMILOLcamiLOL 7 ปีที่แล้ว

    hi dan, i was wondering if you can load a folder of images into Processing, if it is possible please tell my how to do that.
    Thank you.

  • @lungdart85
    @lungdart85 5 ปีที่แล้ว +1

    Is your distance normalized between 0 and 1? If so, why are all of your scores so low? I would think that there would bound to be some scores higher than a 0.36, but I didn't see any. Could be a bug!

  • @spicytuna08
    @spicytuna08 5 ปีที่แล้ว

    any idea when there are 10000 users buying/not buying 20000 products? i guess the results have to be compiled first. but still that would be 10k by 10k by 20k loop.

  • @Brandflugan
    @Brandflugan 7 ปีที่แล้ว

    Ever heard of RushBallz (IOS) or Boomerang balls (IOS) ? It would be awesome if you could make a challenge similar to those games

  • @AayushThokchom
    @AayushThokchom 7 ปีที่แล้ว

    A doubt!! In compareSimilarity(), how come b.name is always Leon? data.users contains all users. Doesn't sort will pass all the users name as (a,b) argument. Why Leon is constant and other names changes in argument 'a'.

    • @lungdart85
      @lungdart85 5 ปีที่แล้ว

      The console likely is only showing the last N logs. The last N logs were comparing users to Leon.

  • @francescopodesta4339
    @francescopodesta4339 3 ปีที่แล้ว

    7:17 I think that 13 is in the wrong place

  • @Daniel20030
    @Daniel20030 7 ปีที่แล้ว +3

    Daniel, why is this video not public yet? Forgot it?

    • @RitobanRoyChowdhury
      @RitobanRoyChowdhury 7 ปีที่แล้ว

      No, he makes them public one at a time (for reasons that remain hidden from me).

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว +12

      It's possible I'm wrong about this, some reasons why I think (?) releasing one video per day as opposed to all at once: a) people miss parts 1 and 2 if all at once since notifications send you to the latest (part 3), b) youtube's algorithms like channels that release new content regularly so try to do 9/10am every morning, c) i get more views / traffic this way? Still learning the best way to do all this.

  • @stedi1986
    @stedi1986 7 ปีที่แล้ว +4

    At 7:24, how is 5 > 13 ?

    • @MohitKarangiya
      @MohitKarangiya 7 ปีที่แล้ว +2

      Javascript sorts alphabetically. This means that "13" is lower than "5", because "1" is lower than "5".
      You can try this function though,
      function sorter(a, b) {
      if (a < b) return -1; // any negative number works
      if (a > b) return 1; // any positive number works
      return 0; // equal values MUST yield zero
      }

    • @mtrelkenty8115
      @mtrelkenty8115 3 ปีที่แล้ว

      Mohit Karangiya that doesn’t explain it, something’s wrong there.

  • @kurekureci
    @kurekureci 7 ปีที่แล้ว +3

    Coding challenge: Optimize NASA code.
    (its actually real)

    • @TheCodingTrain
      @TheCodingTrain  7 ปีที่แล้ว

      Links please!

    • @kurekureci
      @kurekureci 7 ปีที่แล้ว

      Here: futurism.com/thousands-of-dollars-up-for-grabs-in-nasa-coding-challenge/
      Dont know if its real though...

    • @ThiefKingBakuraX
      @ThiefKingBakuraX 7 ปีที่แล้ว +2

      The Coding Train oh solve google hash code problem 1 2017 more realistic

    • @lionpersia
      @lionpersia 5 ปีที่แล้ว

      @@kurekureci Hey, I went to the link and read the article. I'm a BSc in Maths and I know some FORTRAN. Too bad that I'm not eligible for the bounties though, since I'm a UK citizen. Is there any workaround?

  • @CtgColdHammer
    @CtgColdHammer 7 ปีที่แล้ว +1

    Do you drink a can of monster before each video?

  • @creysys8884
    @creysys8884 7 ปีที่แล้ว

    neigbhors

  • @mrz9900
    @mrz9900 7 ปีที่แล้ว

    hia

  • @sarvagyaagarwal2823
    @sarvagyaagarwal2823 7 ปีที่แล้ว +2

    Are all your videos targeted to programming noobs ? Are there any videos for people already well versed in programming ? For example : i can't stand you explaining sorting for 5 minutes :P

    • @blasttrash
      @blasttrash 6 ปีที่แล้ว +2

      From his wiki page, I gather that his background is more into math and arts. The fact that his videos appeal to noobs make them interesting I guess coz he dabs with wide array of topics. If he did not explain perlin noise or fractals first you wouldn't know what he was talking about in first place.
      But yeah sorting is too basic I guess. You can watch videos at 2-3x speed. Use J,K,L shortcuts to quickly move back 10 secs, pause, move forward 10 secs.