function [alpha,w,b]=reestimate(X,Y,alpha0, alpha_prune,gamma_a,gamma_b)
  if (~exist('gamma_a','var')), gamma_a=0; end
  if (~exist('gamma_b','var')), gamma_b=0; end
  
  alpha_prune_default=1E3;
  alpha_reg_default=1E-5;
  if iscell(X)
    n=size(X{1},1);
    ks=cellfun('size', X,2); kall=sum(ks);
    if (~exist('alpha_prune','var')), alpha_prune=2*alpha_prune_default; end
    if (~exist('alpha0','var')), alpha0=alpha_reg_default*ones(kall,1); end
    if (exist('alpha0', 'var') && length(alpha0)==1 && kall>1)
      alpha0=alpha0*ones(kall,1);
    end
    [alpha,w,b]=reestimate_phi(X,Y,alpha0, alpha_prune,gamma_a,gamma_b);
  else
    C=max(Y); [n,k]=size(X);
    if (C~=2), error('defect branch'); end
    if (~exist('alpha_prune','var')), alpha_prune=alpha_prune_default; end
    kall=k*(C-1);
    if (~exist('alpha0','var')), alpha0=alpha_reg_default*ones(kall,1); end
    if (exist('alpha0', 'var') && length(alpha0)==1 && kall>1)
      alpha0=alpha0*ones(kall,1);
    end
    [alpha,w,b]=reestimate_X(X,Y,alpha0, alpha_prune,gamma_a,gamma_b);
  end
