Won't You be my Nearest Neighbor?
-
Upload
woody-schneider -
Category
Technology
-
view
712 -
download
2
Transcript of Won't You be my Nearest Neighbor?
![Page 1: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/1.jpg)
Nearest Neighbor
An Explanation of Nearest Neighbor and how to use it to get to
know your data in Matlab
![Page 2: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/2.jpg)
Match Making for Soda Lovers
![Page 3: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/3.jpg)
![Page 4: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/4.jpg)
Sw
eetness
![Page 5: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/5.jpg)
Sw
eetness
Carbonation
![Page 6: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/6.jpg)
Sw
eetness
Carbonation
Price
![Page 7: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/7.jpg)
Sw
eetness
Carbonation
Price
Acidity
![Page 8: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/8.jpg)
Sw
eetness
Carbonation
Price
Acidity
Caffeination
![Page 9: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/9.jpg)
Sw
eetness
Carbonation
Price
Acidity
Caffeination
Etc.
![Page 10: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/10.jpg)
Sw
eetness
Carbonation
Price
Acidity
Caffeination
Etc.
Etc.
![Page 11: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/11.jpg)
Sw
eetness
Carbonation
Price
Acidity
Caffeination
Etc.
Etc.
Etc.
![Page 12: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/12.jpg)
Sweetness
Carbonation
Price
Soda ID Sweetness Carbonation Price
Soda 1 3.5 4.3 $1.00
Soda 2 5.1 4.1 $1.50
Soda 3 4.2 2.2 $2.00
Soda 4 3.1 4.2 $0.75
Soda 5 6 3.0 $0.50
![Page 13: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/13.jpg)
Sweetness
Carbonation
Price
xlsread(filename)csvread(filename)
Sweetness Carbonation Price
3.5 4.3 $1.00
5.1 4.1 $1.50
4.2 2.2 $2.00
3.1 4.2 $0.75
6 3.0 $0.50
Soda Brand
Soda 1
Soda 2
Soda 3
Soda 4
Soda 5
[SODAS, BRANDS] = xlsread(filename)
![Page 14: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/14.jpg)
![Page 15: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/15.jpg)
![Page 16: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/16.jpg)
![Page 17: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/17.jpg)
![Page 18: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/18.jpg)
*
![Page 19: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/19.jpg)
***
**
*
*
**
***
![Page 20: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/20.jpg)
***
**
*
*
**
***
![Page 21: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/21.jpg)
***
**
*
*
**
***
![Page 22: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/22.jpg)
***
**
*
*
**
***
![Page 23: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/23.jpg)
The Basic Math
Differencein Sweetness
Differencein Carbonation
Differencein Price
Sweetness
Carbona
tion
a
b
A^2 + b^2 = c^3
Distance:(in lots of dimensions)
![Page 24: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/24.jpg)
MatlabdsearchnN-Dimensional nearest point search
Syntaxk = dsearchn(SODAS,IDEALS)
rangesearchFind all neighbors specified distance using KDTreeSearcher object
Syntax[idx,D]= rangesearch(SODATREE,IDEALS,r)
![Page 25: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/25.jpg)
MatlabdsearchnN-Dimensional nearest point search
Syntaxk = dsearchn(SODAS,IDEALS)
knnsearchFind k-nearest neighbors using data
Syntax[IDX,D] = knnsearch(SODATREE,IDEALS,r)
For single nearestpoint
For More Neighbors(requires a tree)
![Page 26: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/26.jpg)
Easy One Match SearchdsearchnN-Dimensional nearest point search
SyntaxI = dsearchn(SODAS,IDEALS)
![Page 27: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/27.jpg)
Harder Multi Match SearchBuilding a Tree
Sweetness Carbonation Price
3.5 4.3 $1.00
5.1 4.1 $1.50
4.2 2.2 $2.00
3.1 4.2 $0.75
6 3.0 $0.50
SODATREE = kdtreesearcher(SODAS,'distance')
All the Sodas
![Page 28: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/28.jpg)
Sweetness Carbonation Price
3.5 4.3 $1.00
5.1 4.1 $1.50
4.2 2.2 $2.00
rangesearchFind all neighbors specified distance using KDTreeSearcher object
Syntax[I,D]= rangesearch(SODATREE,IDEALS,r)
**r
Harder Multi Match SearchGetting neighbors
Ideal Sodas
![Page 29: Won't You be my Nearest Neighbor?](https://reader030.fdocuments.in/reader030/viewer/2022032616/55a6ca211a28ab531d8b4808/html5/thumbnails/29.jpg)