{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

12-knn_perceptron

# 12-knn_perceptron - CS246 Mining Massive Datasets Jure...

This preview shows pages 1–12. Sign up to view the full content.

CS246: Mining Massive Datasets Jure Leskovec, Stanford University http://cs246.stanford.edu

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Would like to do prediction: estimate a function f(x) so that y = f(x) Where y can be: Real number : Regression Categorical : Classification Complex object: Ranking of items, Parse tree, etc. Data is labeled : Have many pairs {(x, y)} x … vector of real valued features y … class ({+1, -1}, or a real number) 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 2 X Y X’ Y’ Training and test set
We will talk about the following methods: k-Nearest Neighbor (Instance based learning) Perceptron algorithm Support Vector Machines Decision trees Main question: How to efficiently train (build a model/find model parameters) ? 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Instance based learning Example: Nearest neighbor Keep the whole training dataset: {(x, y)} A query example (vector) q comes Find closest example(s) x* Predict y* Can be used both for regression and classification Recommendation systems 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 4
To make Nearest Neighbor work we need 4 things: Distance metric: Euclidean How many neighbors to look at? One Weighting function (optional): Unused How to fit with the local points? Just predict the same output as the nearest neighbor 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Suppose x 1 ,…, x m are two dimensional: x 1 =(x 11 ,x 12 ), x 2 =(x 21 ,x 22 ), … One can draw nearest neighbor regions: 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 6 d(x i ,x j ) = (x i1 -x j1 ) 2 + (x i2 -x j2 ) 2 d(x i ,x j ) = (x i1 -x j1 ) 2 + (3x i2 -3x j2 ) 2
Distance metric: Euclidean How many neighbors to look at? k Weighting function (optional): Unused How to fit with the local points? Just predict the average output among k nearest neighbors 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 7 k=9

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Distance metric: Euclidean How many neighbors to look at? All of them (!) Weighting function: w i = exp(-d(x i , q) 2 /K w ) Nearby points to query q are weighted more strongly. K w …kernel width. How to fit with the local points? Predict weighted average: Σ w i y i / Σ w i 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 8 K=10 K=20 K=80 d(x i , q) = 0 w i
Given: a set P of n points in R d Goal: Given a query point q NN: find the nearest neighbor p of q in P Range search: find one/all points in P within distance r from q 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 9 q p

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Main memory: Linear scan Tree based: Quadtree kd-tree Hashing: Locality-Sensitive Hashing Secondary storage: R-trees 2/14/2011 Jure Leskovec, Stanford C246: Mining Massive Datasets 10
Simplest spatial structure on Earth!

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern