Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Story
How we grew from 0 to 3 million users
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

Writing our own K Nearest Neighbors in Code - Practical Machine Learning Tutorial with Python p.17

96.4K views
•
May 6, 2016
by
sentdex
YouTube video player
Writing our own K Nearest Neighbors in Code - Practical Machine Learning Tutorial with Python p.17

TL;DR

This content discusses the implementation of a K nearest neighbors function, including the calculation of Euclidean distance. It also mentions the use of numpy and compares the function to scikit-learn's K nearest neighbors algorithm.

Transcript

what is going on everybody and welcome to part 17 of our machine learning tutorial series we've been working on K nearest neighbors and let's get into it don't want to waste any more time here so we've started creating this K nearest neighbors function all we've done so far though is just warn the user when they're trying to do something stupid so ... Read More

Key Insights

  • 👈 Creating a K nearest neighbors function involves calculating Euclidean distances between a prediction point and other data points.
  • 💨 Numpy arrays can be used to perform a faster version of Euclidean distance calculation.
  • 😥 The function appends distances to a list and sorts it to find the K nearest data points.
  • 👥 The most common group is determined using the Counter object from the collections module.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What is the purpose of the K nearest neighbors function?

The K nearest neighbors function is used to calculate the K nearest data points to a prediction point based on the comparison of Euclidean distances.

Q: What is the problem with K nearest neighbors when comparing data points?

The problem is that K nearest neighbors requires comparing the prediction point to all other points in the dataset, making it a slow calculation.

Q: How can the Euclidean distance calculation be improved?

Numpy arrays can be used to perform a faster calculation of Euclidean distance, with a simplified version also available. This saves time and allows for calculations in higher dimensions.

Q: How is the most common group determined in the K nearest neighbors function?

The K nearest neighbors function uses the Counter object from Python's collections module to determine the most common group, taking into account the K nearest data points.

Summary & Key Takeaways

  • The content focuses on creating a K nearest neighbors function and discusses the problem of comparing a data point to other data points to find the closest ones.

  • It explains different versions of the Euclidean distance calculation, including a faster method using numpy arrays.

  • The content also covers appending distances to a list, sorting the list, and obtaining the most common group.

  • Lastly, it mentions the intention to compare the function to scikit-learn's K nearest neighbors algorithm in the next tutorial.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from sentdex 📚

Python: How to Program the Chaikin Money Flow Trading Indicator thumbnail
Python: How to Program the Chaikin Money Flow Trading Indicator
sentdex
Parsing XML - Go Lang Practical Programming Tutorial p.11 thumbnail
Parsing XML - Go Lang Practical Programming Tutorial p.11
sentdex
How to Parse Twitter Data Using Python Effectively thumbnail
How to Parse Twitter Data Using Python Effectively
sentdex
How to Train a Chatbot Using TensorFlow and Python thumbnail
How to Train a Chatbot Using TensorFlow and Python
sentdex
Python: How to Graph the Chaikin Money Flow Trading Indicator in Matplotlib thumbnail
Python: How to Graph the Chaikin Money Flow Trading Indicator in Matplotlib
sentdex
Python Generator Functions for massive Performance Improvements with Lists thumbnail
Python Generator Functions for massive Performance Improvements with Lists
sentdex

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots
  • Open Graph Checker

Company

  • About us
  • Our Story
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.