get_dim_and_tr.m

来自「该文件里面包含了三个AdaBoost算法」· M 代码 · 共 60 行

M
60
字号
%   The algorithms implemented by Alexander Vezhnevets aka Vezhnick
%   <a>href="mailto:vezhnick@gmail.com">vezhnick@gmail.com</a>
%
%   Copyright (C) 2005, Vezhnevets Alexander
%   vezhnick@gmail.com
%   
%   This file is part of GML Matlab Toolbox
%   For conditions of distribution and use, see the accompanying License.txt file.
%
%   get_dim_and_tr is the function, that returns dimension and threshold of
%   tree node
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%
%    output = get_dim_and_tr(tree_node, output)
%    ---------------------------------------------------------------------------------
%    Arguments:
%           tree_node - a node of classification tree
%           output    - vector of dimensions and thresholds. Result fo
%                       current node would be concatinated to it
%    Return:
%           output    - a vector of thresholds and dimensions. It has the
%                       following format:
%                       [dimension threshold left/right ...]
%                       left/right is  [-1, +1] number, wich signifies if
%                       current threshold is eather left or right

function output = get_dim_and_tr(tree_node, output)

if(nargin < 2)
  output = [];
end

if(length(tree_node.parent) > 0)
  output = get_dim_and_tr(tree_node.parent, output);
end

output(end+1) = tree_node.dim;

if( length(tree_node.right_constrain) > 0)
  output(end+1) = tree_node.right_constrain;
  output(end+1) = -1;
elseif( length(tree_node.left_constrain) > 0)
  output(end+1) = tree_node.left_constrain;
  output(end+1) = +1;
end

% function [dim, tr, signum] = get_dim_and_tr(tree_node)
% 
% dim = tree_node.dim;
% 
% 
% 
% if( length(tree_node.right_constrain) > 0)
%   tr = tree_node.right_constrain;
%   signum = -1;
% end
% if( length(tree_node.left_constrain) > 0)
%   tr = tree_node.left_constrain;
%   signum = +1;
% end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?