store_grabbag.m
来自「最新的模式识别分类工具箱,希望对朋友们有用!」· M 代码 · 共 56 行
M
56 行
function D = Store_Grabbag(train_features, train_targets, Knn, region)% Classify using the store-grabbag algorithm (an improvement on the nearest neighbor)% Inputs:% features - Train features% targets - Train targets% Knn - Number of nearest neighbors% region - Decision region vector: [-x x -y y number_of_points]%% Outputs% D - Decision sufraceL = length(train_features);N = region(5);D = zeros(N);%Placing first sample in STOREStore_features(:,1) = train_features(:,1);Store_targets = train_targets(1);Grabbag_targets = [];Grabbag_features = [];for i = 2:L, target = Knn_Rule(train_features(:,i), Store_features, Store_targets, Knn); if target == train_targets(i) Grabbag_features = [Grabbag_features , train_features(:,i)]; Grabbag_targets = [Grabbag_targets train_targets(i)]; else Store_features = [Store_features, train_features(:,i)]; Store_targets = [Store_targets train_targets(i)]; end end New_Grabbag_features = Grabbag_features;while (Grabbag_features ~= New_Grabbag_features) Grabbag_features = New_Grabbag_features; New_Grabbag_targets = []; for i = 1:length(Grabbag_features), target = Knn_Rule(Grabbag_features(:,i), Store_features, Store_targets); if target == train_targets(i) New_Grabbag_features = [New_Grabbag_features, train_features(:,i)]; New_Grabbag_targets = [New_Grabbag_targets train_targets(i)]; else Store_features = [Store_features, train_features(:,i)]; Store_targets = [Store_targets , train_targets(i)]; end endend disp(['Calling Nearest Neighbor algorithm']);D = Nearest_Neighbor(Store_features, Store_targets, Knn, region);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?