knnsearch
转载:https://blog.csdn.net/bushixiaofan/article/details/27700299
K近邻算法是找到K个最近的邻居。
IDX = knnsearch(X,Y) finds the nearest neighbor in X for each point in
Y. X is an MX-by-N matrix and Y is an MY-by-N matrix. Rows of X and Y
correspond to observations and columns correspond to variables. IDX is
a column vector with MY rows. Each row in IDX contains the index of
the nearest neighbor in X for the corresponding row in Y.
IDX = knnsearch(X, Y) 在向量集合X中找到分别与向量集合Y中每个行向量最近的邻居。X大小为MX-by-N矩阵,Y为大小MY-by-N的矩阵,X和Y的行对应观测的样本
列对应每个样本的变量。IDX是一个MY维的列向量,IDX的每一行对应着Y每一个观测在X中最近邻的索引值。
[IDX, D] = knnsearch(X,Y) returns a MY-by-1 vector D containing the
distances between each row of Y and its closest point in X.
[IDX, D]= knnsearch(X,Y,'NAME1',VALUE1,...,'NAMEN',VALUEN) specifies
optional argument name/value pairs:
Name Value
'K' A positive integer, K, specifying the number of nearest
neighbors in X to find for each point in Y. Default is
1. IDX and D are MY-by-K matrices. D sorts the
distances in each row in ascending order. Each row in
IDX contains the indices of K closest neighbors in X
corresponding to the K smallest distances in D.
“K”表示最近邻个数,返回值D是按行升序排列。
'NSMethod' Nearest neighbors search method. Value is either:
搜寻的方法参数
'Distance' A string or a function handle specifying the distance
选择何种距离作为最近邻的度量标准
Example:
% Find 2 nearest neighbors in X and the corresponding values to each
% point in Y using the distance metric 'cityblock'
X = randn(100,5);
Y = randn(25, 5);
[idx, dist] = knnsearch(X,Y,'dist','cityblock','k',2);
knnsearch的更多相关文章
- matlab查找最临近搜索knnsearch
Idx = knnsearch(X,Y) finds the nearest neighbor in X for each query point in Y and returns the indic ...
- 闪电动画模拟(Dielectric Breakdown Model)附源码
当两个物体之间存在较大的电势差时会出现放电现象,比如生活中常见的闪电现象,闪电形成的条件就是云层积累了大量负电荷之后与地面之间形成了强大的电势差.目前关于闪电建模的方法比较少,下面介绍一种利用电介击穿 ...
- paper 130:MatLab分类器大全(svm,knn,随机森林等)
train_data是训练特征数据, train_label是分类标签.Predict_label是预测的标签.MatLab训练数据, 得到语义标签向量 Scores(概率输出).1.逻辑回归(多项式 ...
- paper 120:计算距离矩阵的函数的pdist和pdist2函数
matlab中自带的计算距离矩阵的函数有两个pdist和pdist2.前者计算一个向量自身的距离矩阵,后者计算两个向量之间的距离矩阵.基本调用形式如下: D = pdist(X) D = pdist2 ...
- 基于网格的波动方程模拟(Wave equation on mesh)附源码
波动方程是偏微分方程 (PDE) 里的经典方程,它在物理学中有大量应用并经常用来解释空间中的能量传播.波动方程是一个依赖时间的方程,它解释了系统状态是如何随着时间的推移而发生变化.在下面模拟波动方程时 ...
- [SLAM]2D激光线特征提取
Nguyen, V., et al. (2007)."A comparison of line extraction algorithms using 2D range data for i ...
- 学习OpenCV——Surf(特征点篇)&flann
Surf(Speed Up Robust Feature) Surf算法的原理 ...
- OpenCV图像Surf与flann特征点(转载)
Surf(Speed Up Robust Feature) Surf算法的原理 ...
- OpenCV探索之路(二十三):特征检测和特征匹配方法汇总
一幅图像中总存在着其独特的像素点,这些点我们可以认为就是这幅图像的特征,成为特征点.计算机视觉领域中的很重要的图像特征匹配就是一特征点为基础而进行的,所以,如何定义和找出一幅图像中的特征点就非常重要. ...
随机推荐
- 8-Flink中的窗口
戳更多文章: 1-Flink入门 2-本地环境搭建&构建第一个Flink应用 3-DataSet API 4-DataSteam API 5-集群部署 6-分布式缓存 7-重启策略 8-Fli ...
- Centos7+LVS-NAT+apache实验
一.简介 1.理论已经在上一篇博客简述,不了解得可以看看 https://www.cnblogs.com/zhangxingeng/p/10497279.html 2.LVS-NAT优缺点复习 关于这 ...
- javascript小记一则:今天在写VS2005——.NET程序时,写的一个JS图片示例案例
源码如下,如遇调试问题,可以找我解决: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...
- vue-render函数和插槽
Vue render函数,官方文档定义绝大部分时候我们使用template 来创建html 模板,但是纯html 和css都基本上都不具有编程能力,而当我们想使用 javascript的编程能力时,我 ...
- animate-queue和step-animate
Step-animate: 分为3部分:{配置},{step:function(){...},duration:1000} <div id="warpper" style=& ...
- ArcGIS API for JavaScript 入门教程[7] 再讲视图——View的基本属性
[回顾]上篇花大篇幅讲了ArcGIS Server上的数据服务与部分常用可操作图层的创建关系,还讲了OGC的几个规范. 本篇回到JsAPI 4.x的新特性——视图类中来. 在第3篇讲过,4.x将视图从 ...
- 瓦片切图工具gdal2tiles.py改写为纯c++版本
gdal2tiles.py是GDAL库中用于生成TMS瓦片的python代码,支持谷歌墨卡托EPSG:3857与经纬度EPSG:4326两种瓦片,输出png格式图像. gdal2tiles.py Mo ...
- 如何在Android studio上运行从github上下载的RN项目
想要编译别人的RN项目,还是要踩踩坑才能走上正轨啊,分享下我试过多种方法后最喜欢的方法(其实是因为我多次用VS Code编译都是以失败而告终,所以才选择的studio) 注意:这一步是你的开发环境都安 ...
- vue echarts map的使用,页面多图动态自适应
最近在vue中使用echarts时,遇到了一些坑,在此记录一下. 1:echarts map的使用 2:页面多图自适应,只有一个图生效 3:根据设备的dpr,动态的修改了meta标签中的initial ...
- 网络爬虫BeautifulSoup库的使用
使用BeautifulSoup库提取HTML页面信息 #!/usr/bin/python3 import requests from bs4 import BeautifulSoup url='htt ...