K-Nearest Neighbour (Continued) Dr. Xiaowei Huang

Similar documents
Instance-Based Learning.

Instance-Based Learning. Goals for the lecture

Decision Tree (Continued) and K-Nearest Neighbour. Dr. Xiaowei Huang

Data mining. Classification k-nn Classifier. Piotr Paszek. (Piotr Paszek) Data mining k-nn 1 / 20

CSC 411: Lecture 05: Nearest Neighbors

Mathematics of Data. INFO-4604, Applied Machine Learning University of Colorado Boulder. September 5, 2017 Prof. Michael Paul

Data Mining and Machine Learning: Techniques and Algorithms

Nearest Neighbor Classification. Machine Learning Fall 2017

COMPUTATIONAL INTELLIGENCE SEW (INTRODUCTION TO MACHINE LEARNING) SS18. Lecture 6: k-nn Cross-validation Regularization

CISC 4631 Data Mining

Nearest Neighbor Methods

MIT 801. Machine Learning I. [Presented by Anna Bosman] 16 February 2018

Lecture 3. Oct

Nearest Neighbor with KD Trees

Nearest Neighbor with KD Trees

Supervised Learning: Nearest Neighbors

Instance-Based Learning: Nearest neighbor and kernel regression and classificiation

Introduction to Machine Learning Lecture 4. Mehryar Mohri Courant Institute and Google Research

Instance Based Learning. k-nearest Neighbor. Locally weighted regression. Radial basis functions. Case-based reasoning. Lazy and eager learning

Geometric data structures:

Classification and Regression

Data Mining. Lecture 03: Nearest Neighbor Learning

Instance-Based Learning: Nearest neighbor and kernel regression and classificiation

Data Mining. 3.5 Lazy Learners (Instance-Based Learners) Fall Instructor: Dr. Masoud Yaghini. Lazy Learners

7. Nearest neighbors. Learning objectives. Foundations of Machine Learning École Centrale Paris Fall 2015

UVA CS 6316/4501 Fall 2016 Machine Learning. Lecture 15: K-nearest-neighbor Classifier / Bias-Variance Tradeoff. Dr. Yanjun Qi. University of Virginia

CS61BL. Lecture 5: Graphs Sorting

Classifiers and Detection. D.A. Forsyth

Data Mining Classification: Alternative Techniques. Lecture Notes for Chapter 4. Instance-Based Learning. Introduction to Data Mining, 2 nd Edition

K Nearest Neighbor Wrap Up K- Means Clustering. Slides adapted from Prof. Carpuat

Machine Learning Techniques for Data Mining

Slides for Data Mining by I. H. Witten and E. Frank

07 B: Sorting II. CS1102S: Data Structures and Algorithms. Martin Henz. March 5, Generated on Friday 5 th March, 2010, 08:31

Instance and case-based reasoning

Data Mining and Data Warehousing Classification-Lazy Learners

7. Nearest neighbors. Learning objectives. Centre for Computational Biology, Mines ParisTech

Locality- Sensitive Hashing Random Projections for NN Search

Problem 1: Complexity of Update Rules for Logistic Regression

kd-trees Idea: Each level of the tree compares against 1 dimension. Let s us have only two children at each node (instead of 2 d )

DATA MINING LECTURE 10B. Classification k-nearest neighbor classifier Naïve Bayes Logistic Regression Support Vector Machines

UVA CS 4501: Machine Learning. Lecture 10: K-nearest-neighbor Classifier / Bias-Variance Tradeoff. Dr. Yanjun Qi. University of Virginia

Lecture 24: Image Retrieval: Part II. Visual Computing Systems CMU , Fall 2013

Nearest Neighbor Predictors

Statistical Learning Part 2 Nonparametric Learning: The Main Ideas. R. Moeller Hamburg University of Technology

CSE 417T: Introduction to Machine Learning. Lecture 6: Bias-Variance Trade-off. Henry Chai 09/13/18

Distribution-free Predictive Approaches

Kernels and Clustering

Instance-based Learning CE-717: Machine Learning Sharif University of Technology. M. Soleymani Fall 2015

1) Give decision trees to represent the following Boolean functions:

Data Mining Lecture 8: Decision Trees

CS178: Machine Learning and Data Mining. Complexity & Nearest Neighbor Methods

CS S Lecture February 13, 2017

K-Nearest Neighbors. Jia-Bin Huang. Virginia Tech Spring 2019 ECE-5424G / CS-5824

CS489/698 Lecture 2: January 8 th, 2018

Hierarchical Clustering 4/5/17

Going nonparametric: Nearest neighbor methods for regression and classification

CSE373: Data Structures & Algorithms Lecture 11: Implementing Union-Find. Lauren Milne Spring 2015

CS 343: Artificial Intelligence

08 A: Sorting III. CS1102S: Data Structures and Algorithms. Martin Henz. March 10, Generated on Tuesday 9 th March, 2010, 09:58

Case-Based Reasoning. CS 188: Artificial Intelligence Fall Nearest-Neighbor Classification. Parametric / Non-parametric.

CS 188: Artificial Intelligence Fall 2008

Data Structures in Java. Session 23 Instructor: Bert Huang

{ K 0 (P ); ; K k 1 (P )): k keys of P ( COORD(P) ) { DISC(P): discriminator of P { HISON(P), LOSON(P) Kd-Tree Multidimensional binary search tree Tak

Machine Learning and Pervasive Computing

Lecture 27: Review. Reading: All chapters in ISLR. STATS 202: Data mining and analysis. December 6, 2017

CS570: Introduction to Data Mining

k-nearest Neighbors + Model Selection

Topics In Feature Selection

Nearest neighbors classifiers

Non-Bayesian Classifiers Part I: k-nearest Neighbor Classifier and Distance Functions

K-Nearest Neighbour Classifier. Izabela Moise, Evangelos Pournaras, Dirk Helbing

Introduction to Automated Text Analysis. bit.ly/poir599

ELEC6910Q Analytics and Systems for Social Media and Big Data Applications Lecture 4. Prof. James She

Instance-based Learning

CS 229 Midterm Review

CSE 373 OCTOBER 25 TH B-TREES

CSC 411 Lecture 4: Ensembles I

Announcements. CS 188: Artificial Intelligence Spring Generative vs. Discriminative. Classification: Feature Vectors. Project 4: due Friday.

Data Mining and Machine Learning. Instance-Based Learning. Rote Learning k Nearest-Neighbor Classification. IBL and Rule Learning

Big Data Analytics. Special Topics for Computer Science CSE CSE April 14

Machine Learning: k-nearest Neighbors. Lecture 08. Razvan C. Bunescu School of Electrical Engineering and Computer Science

Data Mining. Part 2. Data Understanding and Preparation. 2.4 Data Transformation. Spring Instructor: Dr. Masoud Yaghini. Data Transformation

Chapter 2: Classification & Prediction

COMP Data Structures

MODULE 7 Nearest Neighbour Classifier and its variants LESSON 11. Nearest Neighbour Classifier. Keywords: K Neighbours, Weighted, Nearest Neighbour

CS7267 MACHINE LEARNING NEAREST NEIGHBOR ALGORITHM. Mingon Kang, PhD Computer Science, Kennesaw State University

Final Exam DATA MINING I - 1DL360

Model Assessment and Selection. Reference: The Elements of Statistical Learning, by T. Hastie, R. Tibshirani, J. Friedman, Springer

Data Structures and Algorithms

Support Vector Machines + Classification for IR

Task Description: Finding Similar Documents. Document Retrieval. Case Study 2: Document Retrieval

Density estimation. In density estimation problems, we are given a random from an unknown density. Our objective is to estimate

Feature Extractors. CS 188: Artificial Intelligence Fall Nearest-Neighbor Classification. The Perceptron Update Rule.

University of Cambridge Engineering Part IIB Paper 4F10: Statistical Pattern Processing Handout 11: Non-Parametric Techniques

BITS F464: MACHINE LEARNING

Instance-based Learning

University of Cambridge Engineering Part IIB Paper 4F10: Statistical Pattern Processing Handout 11: Non-Parametric Techniques

Feature Selection. CE-725: Statistical Pattern Recognition Sharif University of Technology Spring Soleymani

Data Mining in Bioinformatics Day 1: Classification

Adaptive Metric Nearest Neighbor Classification

Transcription:

K-Nearest Neighbour (Continued) Dr. Xiaowei Huang https://cgi.csc.liv.ac.uk/~xiaowei/

A few things: No lectures on Week 7 (i.e., the week starting from Monday 5 th November), and Week 11 (i.e., the week starting from Monday 3 rd December) Labs will continue up to Week 7 No Class Tests A final exam, MCQ, 80% (the other 20% are on the CAs)

Up to now, Recap basic knowledge Decision tree learning k-nn classification What is k-nearest-neighbor classification How can we determine similarity/distance Standardizing numeric features (leave this to you)

Nearest Neighbor When to Consider Less than 20 attributes per instance Lots of training data Advantages Training is very fast Learn complex target functions Do not lose information Disadvantages Slow at query time Easily fooled by irrelevant attributes

Today s Topics K-NN regression Distance-weighted nearest neighbor Speeding up k-nn edited nearest neighbour k-d trees for nearest neighbour identification

k-nearest-neighbor regression learning stage given a training set (x (1), y (1) )... (x (m), y (m) ), do nothing (it s sometimes called a lazy learner) classification stage given: an instance x (q) to classify find the k training-set instances (x (1), y (1) )... (x (k), y (k) ) that are most similar to x (q) return the value Average over neighbours values

Distance-weighted nearest neighbor We can have instances contribute to a prediction according to their distance from x (q) classification: Intuition: instances closer to the current one is more important. regression: reciprocal of the distance

Issues Choosing k Increasing k reduces variance, increases bias For high-dimensional space, problem that the nearest neighbor may not be very close at all! Memory-based technique. Must make a pass through the data for each classification. This can be prohibitive for large data sets.

Nearest neighbour problem Given sample S = ((x 1,y 1 ),...,(x m,y m )) and a test point x, it is to find the nearest k neighbours of x. Note: for the algorithms, dimensionality N, i.e., number of features, is crucial.

Efficient Indexing: N=2 Algorithm compute Voronoi diagram in O(m log m) See algorithm in https://en.wikipedia.org/wiki/fortune's_algorithm use point location data structure to determine nearest neighbours complexity: O(m) space, O(log m) time.

Efficient Indexing: N>2 Voronoi diagram: size in O(m N/2 ) Linear algorithm (no pre-processing): compute distance x x i for all i [1, m]. complexity of distance computation: Ω(N m). no additional space needed. k-nn is a lazy learning algorithm does virtually nothing at training time but classification/prediction time can be costly when the training set is large

Efficient Indexing: N>2 two general strategies for alleviating this weakness don t retain every training instance (edited nearest neighbor) pre-processing. Use a smart data structure to look up nearest neighbors (e.g. a k-d tree)

Edited instance-based learning select a subset of the instances that still provide accurate classifications incremental deletion Q1: Does ordering matter? incremental growth Q2: If following the optimal ordering, do the two approaches produce the same subset of instances?

k-d trees a k-d tree is similar to a decision tree except that each internal node stores one instance splits on the median value of the feature having the highest variance

Construction of k-d tree median value of the feature having the highest variance? -- point f, x 1 = 6 x 1 >6 f

Construction of k-d tree median value of the feature having the highest variance? -- point f, x 1 = 6 -- point c, x 2 = 10 and point h, x 2 = 5 x 1 >6 f x 2 >10 c x 2 >5 h

Construction of k-d tree There can be other methods of constructing k-d trees, see e.g., https://en.wikipedia.org/wiki/kd_tree#nearest_neighbour_search

Finding nearest neighbors with a k-d tree use branch-and-bound search priority queue stores nodes considered lower bound on their distance to query instance lower bound given by distance using a single feature average case: O(log 2 m) worst case: O(m) where m is the size of the training-set

Finding nearest neighbours in a k-d tree Intuitively, for a pair (node,value), value represents the smallest guaranteed distance, i.e., greatest lower bound up to now, from the instance x (q) to the set of instances over which node is the selected one to split For example, the set of instances where root is the selected one to split over is the whole training set. (root,0) means that at the beginning, the guaranteed smallest distance to the training set is 0

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

k-d tree example (Manhattan distance)

Extended Materials: Voronoi Diagram Generation https://en.wikipedia.org/wiki/voronoi_diagram https://courses.cs.washington.edu/courses/cse326/00wi/projects/vor onoi.html