Fullsearch: Difference between revisions
imported>Jeremy (Importing text file) |
imported>Jeremy (Importing text file) |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Exhaustive Search Algorithm. | Exhaustive Search Algorithm. | ||
===Synopsis=== | ===Synopsis=== | ||
:[desgn,fval] = fullsearch(fun,X,Nx_sub,P1,P2, ...); | :[desgn,fval] = fullsearch(fun,X,Nx_sub,P1,P2, ...); | ||
===Description=== | ===Description=== | ||
Fullsearch selects the Nx_sub variables in the ''M'' by ''Nx'' matrix X that minimizes fun. This can be used for variable selection. The algorithm should only be used for small problems because calculation time increases significantly with the size of the problem. fun is the name of the function (defined as a character string of an inline object) to be minimized. The function is called with the FEVAL function as follows: feval(fun,X,P1,P2,....), where X is the first argument for fun and P1, P2, ... the additional arguments of fun. | Fullsearch selects the Nx_sub variables in the ''M'' by ''Nx'' matrix X that minimizes fun. This can be used for variable selection. The algorithm should only be used for small problems because calculation time increases significantly with the size of the problem. fun is the name of the function (defined as a character string of an inline object) to be minimized. The function is called with the FEVAL function as follows: feval(fun,X,P1,P2,....), where X is the first argument for fun and P1, P2, ... the additional arguments of fun. | ||
The output desgn is a matrix (class "logical") with the same size as X (''M'' by ''Nx'') with 1's where the variables where selected and 0's otherwise. Output fval has the ''M'' corresponding values of the objective function sorted in ascending order. | The output desgn is a matrix (class "logical") with the same size as X (''M'' by ''Nx'') with 1's where the variables where selected and 0's otherwise. Output fval has the ''M'' corresponding values of the objective function sorted in ascending order. | ||
===Examples=== | ===Examples=== | ||
find which 2of 3 variables minimizes the inline function g: | find which 2of 3 variables minimizes the inline function g: | ||
x = [0:10]'; | x = [0:10]'; | ||
x = [x x.\^2 randn(11,1)\*10]; | x = [x x.\^2 randn(11,1)\*10]; | ||
y = x\*[1 1 0]'; | y = x\*[1 1 0]'; | ||
g = inline('sum((y-x\*(x\y)).\^2)'); | g = inline('sum((y-x\*(x\y)).\^2)'); | ||
[d,fv] = fullsearch(g,x,2,y); | [d,fv] = fullsearch(g,x,2,y); | ||
find the 2 variables that minimize the cross-validation error for PCR, noting that the output from CROSSVAL is a vector and g should return a scalar | find the 2 variables that minimize the cross-validation error for PCR, noting that the output from CROSSVAL is a vector and g should return a scalar | ||
load plsdatad | load plsdatad | ||
x = xblock1.data; | x = xblock1.data; | ||
y = yblock1.data; | y = yblock1.data; | ||
g = inline('min(sum(crossval(x,y,''pcr'',{''con'' 3},1,0)))','x','y'); | g = inline('min(sum(crossval(x,y,''pcr'',{''con'' 3},1,0)))','x','y'); | ||
[d,fv] = fullsearch(g,x,2,y); %takes a while if Nx_sub is > 2 | [d,fv] = fullsearch(g,x,2,y); %takes a while if Nx_sub is > 2 | ||
===See Also=== | ===See Also=== | ||
[[calibsel]], [[crossval]], [[genalg]] | [[calibsel]], [[crossval]], [[genalg]] |
Revision as of 15:25, 3 September 2008
Purpose
Exhaustive Search Algorithm.
Synopsis
- [desgn,fval] = fullsearch(fun,X,Nx_sub,P1,P2, ...);
Description
Fullsearch selects the Nx_sub variables in the M by Nx matrix X that minimizes fun. This can be used for variable selection. The algorithm should only be used for small problems because calculation time increases significantly with the size of the problem. fun is the name of the function (defined as a character string of an inline object) to be minimized. The function is called with the FEVAL function as follows: feval(fun,X,P1,P2,....), where X is the first argument for fun and P1, P2, ... the additional arguments of fun.
The output desgn is a matrix (class "logical") with the same size as X (M by Nx) with 1's where the variables where selected and 0's otherwise. Output fval has the M corresponding values of the objective function sorted in ascending order.
Examples
find which 2of 3 variables minimizes the inline function g:
x = [0:10]';
x = [x x.\^2 randn(11,1)\*10];
y = x\*[1 1 0]';
g = inline('sum((y-x\*(x\y)).\^2)');
[d,fv] = fullsearch(g,x,2,y);
find the 2 variables that minimize the cross-validation error for PCR, noting that the output from CROSSVAL is a vector and g should return a scalar
load plsdatad
x = xblock1.data;
y = yblock1.data;
g = inline('min(sum(crossval(x,y,pcr,{con 3},1,0)))','x','y');
[d,fv] = fullsearch(g,x,2,y); %takes a while if Nx_sub is > 2