RASAC 入门
来源:互联网 发布:wp10记录仪软件 编辑:程序博客网 时间:2024/06/04 00:14
RASAC——Wikipedia(Random sampleconsensus)
RASAC算法是一种学习技术,通过随机观察样本数据估计模型参数。给定一个数据集包含内点和外点,RASAC使用投票方案找到优化的拟合结果。数据集中的数据元素被用来投票给一个或多个模型。这个投票方案的实施基于两个假设:噪声特征不会对任何单一模型(少数异常值)进行一致性投票;有足够的特征得到好的模型(丢失数据少)。
RASAC算法主要由两个步骤组成:
1.从输入数据集中随机抽取包含最小数据项的样本子集。一个拟合模型和相应的模型参数仅使用该样本子集的元素来计算。样本子集的基数足够确定模型参数的最小值。
2.算法检查整个数据集的那些元素和第一步获得的模型参数所实例化的模型相一致。如果一个数据元素不符合由估计模型参数集合所实例化的拟合模型,那么它将被认为是一个异常值,该模型参数在一个误差阈值内,定义了由噪声影响引起的最大偏差。
拟合模型获得的内点集称为一致集。RASAC反复迭代上述两步,直到某些迭代中获得足够的内点(一致集)。RASAC算法的输入是一组观测数据值。一种将某种模型拟合到观测值的方法,以及一些置信参数。其通过重复以下步骤达到目标:
1.随机选择原始数据的一个子集,这个子集称为假设内点;
2.用一个模型拟合这个子集;
3.然后用这个模型测试所有的其他数据,根据一些特定模型的损失函数,这些点拟合了一个非常好的估计模型,而这些点被认为是一致集的一部分。
4.如果有足够多的点被归类为一致集的一部分,那么这个估计模型就相当不错。
5.然后,使用一致集的所有元素重新估计,来改进模型。
这个过程重复固定的次数,每次都产生一个被拒绝的模型,因为太少的点是一致集的一部分,或者是一个改进的模型和其相应的一致集的大小的原因。在后一种情况下,如果它的一致集比先前保存的模型大,我们就保留了这个改进的模型。
MATLAB实现过程
function [bestParameter1,bestParameter2]= ransac_demo(data,num,iter,threshDist,inlierRatio)
% data: a 2xn dataset with #n data points
% num: the minimum number of points. Forline fitting problem, num=2
% iter: the number of iterations
% threshDist: the threshold of thedistances between points and the fitting line
% inlierRatio: the threshold of the numberof inliers
%% Plot the data points
figure;plot(data(1,:),data(2,:),'o');hold on;
number = size(data,2); % Total number ofpoints
bestInNum = 0; % Best fitting line withlargest number of inliers
bestParameter1=0;bestParameter2=0; %parameters for best fitting line
for i=1:iter
%% Randomly select 2 points
idx = randperm(number,num); sample = data(:,idx);
%% Compute the distances between all pointswith the fitting line
kLine = sample(:,2)-sample(:,1);% twopoints relative distance
kLineNorm = kLine/norm(kLine);
normVector = [-kLineNorm(2),kLineNorm(1)];%Ax+By+C=0A=-kLineNorm(2),B=kLineNorm(1)
distance = normVector*(data - repmat(sample(:,1),1,number));
%% Compute the inliers with distancessmaller than the threshold
inlierIdx = find(abs(distance)<=threshDist);
inlierNum = length(inlierIdx);
%% Update the number of inliers and fittingmodel if better model is found
if inlierNum>=round(inlierRatio*number)&& inlierNum>bestInNum
bestInNum = inlierNum;
parameter1 = (sample(2,2)-sample(2,1))/(sample(1,2)-sample(1,1));
parameter2 = sample(2,1)-parameter1*sample(1,1);
bestParameter1=parameter1; bestParameter2=parameter2;
end
end
%% Plot the best fitting line
xAxis = -number/2:number/2;
yAxis = bestParameter1*xAxis + bestParameter2;
plot(xAxis,yAxis,'r-','LineWidth',2);
RASAC的缺点是:
1.时间没有上限
2.阈值设置问题(要求设置特定的阈值)
- RASAC 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- 入门
- Django实战开发遇到一些问题和解决方法
- 《jenkins部署》
- LESS预处理器
- 最大似然估计和最小二乘法
- 02React的JSX 与Style
- RASAC 入门
- DB2 SQL0668N Operation not allowed for reason code "7" on table
- bzoj 1827: [Usaco2010 Mar]gather 奶牛大集会
- oracle学习笔记
- C语言经典知识示例之01怎样确定float类型变量的有效数字个数
- leetcode 718( Maximum Length of Repeated Subarray)
- 【POJ
- mysql JDBC URL格式各个参数详解
- Target Sum