Fullsearch: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
(Importing text file)
imported>Bob
No edit summary
Line 1: Line 1:
===Purpose===
===Purpose===


Line 10: Line 9:
===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 <tt>Nx_sub</tt> variables in the <tt>M</tt> by <tt>Nx</tt> matrix <tt>X</tt> that minimizes <tt>fun</tt>. 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. <tt>fun</tt> 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: <tt>feval(fun,X,P1,P2,....)</tt>, where <tt>X</tt> is the first argument for <tt>fun</tt> and <tt>P1, P2</tt>, ... the additional arguments of <tt>fun</tt>.


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 <tt>desgn</tt> is a matrix (class "logical") with the same size as <tt>X</tt> (<tt>M</tt> by <tt>Nx</tt>) with 1's where the variables where selected and 0's otherwise. Output <tt>fval</tt> has the <tt>M</tt> corresponding values of the objective function sorted in ascending order.
 
===Examples===


find which 2of 3 variables minimizes the inline function g:
====Inputs====


  x = [0:10]';
* '''fun''' = name of the function, a character string of an inline object.
* '''X''' = input data.
* '''Nx_sub''' = subset of original variables in <tt>X</tt>; <tt>Nx_sub</tt> < <tt>Nx</tt>.
* '''P1, P2 ...''' = parameters for <tt>fun</tt>.


  x = [x x.\^2 randn(11,1)\*10];
====Outputs====


  y = x\*[1 1 0]';
* '''desgn''' = logical matrix, M by Nx, with 1's for selected variables and 0's otherwise.


  g = inline('sum((y-x\*(x\y)).\^2)');
===Examples===


   [d,fv] = fullsearch(g,x,2,y);
find which 2 of 3 variables minimizes the inline function g:
<pre>
  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);</pre>


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
 
<pre>
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</pre>
   [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:32, 9 October 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.

Inputs

  • fun = name of the function, a character string of an inline object.
  • X = input data.
  • Nx_sub = subset of original variables in X; Nx_sub < Nx.
  • P1, P2 ... = parameters for fun.

Outputs

  • desgn = logical matrix, M by Nx, with 1's for selected variables and 0's otherwise.

Examples

find which 2 of 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

See Also

calibsel, crossval, genalg