function [et,eu]=experiment_isolet(method,gamma_A,gamma_I);

% Isolet Experiment
% [et,eu]=experiment_isolet(method,gamma_A,gamma_I);
% et: error rates on test set 
% eu: error rates on training set
% method: 'svm', 'rlsc', 'lapsvm',' laprlsc', 'tsvm' (you need to have
%                   saved model files for tsvm; check below)
%
% Author: Vikas Sindhwani (vikass@cs.uchicago.edu)
% June 2004

load isolet.mat
% X Y Xt Yt labs
sigma=10;

options=ml_options('Kernel','rbf', 'KernelParam', sigma, ...
                        'NN',6,'gamma_A',gamma_A,'gamma_I',gamma_I);
 
                     
disp('Computing Kernels');                    
K=calckernel('rbf',sigma,X);
KT=calckernel('rbf',sigma,X,Xt);
disp('Done.');                    



if strcmp(method,'lapsvm') | strcmp(method, 'laprlsc')
    L=laplacian(X,'nn',options);
end



for i=1:30
    
    y=labs(:,i);
    lab=find(y);
    unlab=find(y==0);
    Yu=Y(unlab);
    r=sum(Yt==-1)/length(Yt);
    
switch method
    
case 'rlsc'
    [alpha,b]=rlsc(K(lab,lab),y(lab),options.gamma_A);
    fu=K(unlab,lab)*alpha; 
    ft=KT(:,lab)*alpha;
    
    
case 'svm'
    [alpha,b]=svm(K(lab,lab),y(lab),options.gamma_A);
    fu=K(unlab,lab)*alpha; 
    ft=KT(:,lab)*alpha;
        
case 'laprlsc'
    [alpha,b]=laprlsc(K,y,L,options.gamma_A,options.gamma_I);
    fu=K(unlab,:)*alpha;
    ft=KT*alpha;
    
case 'lapsvm'
    [alpha,b]=lapsvm(K,y,L,options.gamma_A,options.gamma_I);
    fu=K(unlab,:)*alpha; 
    ft=KT*alpha;
    
case 'tsvm' % need to have TSVM models in the following directory.
    warning('You need to run TSVM separately and generate model files');
    [alpha,b,svs]=readtsvmmodel(['RESULTS_TSVM/model_' num2str(i)]);
    fu=calckernel('rbf',sigma,svs,X(unlab,:))*alpha; 
    ft=calckernel('rbf',sigma,svs,Xt)*alpha;
    
end

bt=breakeven(ft,Yt,@pre_rec_equal);
bu=breakeven(fu,Yu,@pre_rec_equal);



et(i)=evaluate(sign(ft-bt),Yt);
eu(i)=evaluate(sign(fu-bu),Yu);


[i et(i) eu(i) ]

end

function [alpha,b,svs]=readtsvmmodel(file,i)
% use Anton Schwaighofer's SVMLight interface routines
    [alpha,svs]=svmlread(file);
    b=alpha(9);
    alpha=alpha(10:end);
    svs=svs(10:end,:);

function e=evaluate(a,b);
   e=sum(a~=b)/length(b)*100;
   
 function b=get_bias(v,r);
      v1=sort(v);
      p=ceil(r*length(v));
      b=v1(p);
      
