My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
PageName  
Updated Feb 13, 2010 by robin.girard0

#How to use the package

Introduction

The package can be sourced globaly using

source('Make.R')
Make()

Then a simple example of use is

 require(MASS)

####### Set what you want .... #################
K=2; #number of class
n=10; #
p=1000 # dimension
    mu=array(0,c(p,K))
    mu[1:4,2]= mu[1:4,2]+c(0.01,0.5,0.02,0.5)/3
    Cdiag=array(0.01,2,p)
##################################################    
   
#### Create the learning set  
X=NULL; y=NULL;
   for (k in 1:K)
   {
       X=cbind(X,array(C^(1/2),c(p,n))*(matrix(rnorm(p*n),nrow=p,ncol=n))+array(mu[,k],c(p,n)));
       y=c(y,array(k,n))
   }

######## Learn 
    LearnedLDAF=learnLinearRule(t(X),y,'Fisher') 
    LearnedLDAU=learnLinearRule(t(X),y,'UnivThresh',r=1) 
    LearnedLDAFDR=tune.LDA(t(X),y,'FDRThresh',q=10^(-2:-12)/log(p)) #Cross validation
#######

#### Create the testing set
X=NULL; y=NULL;
   for (k in 1:K)
   {
       X=cbind(X,array(C^(1/2),c(p,n))*(matrix(rnorm(p*n),nrow=p,ncol=n))+array(mu[,k],c(p,n)));
       y=c(y,array(k,n))
   }

#### Predict .... 
    UnivScore=mean((y!=predict(LearnedLDAU,t(X)))) ;
    FDRScore=mean((y!=predict(LearnedLDAFDR,t(X)))) ;
    FisherScore= mean((y!=predict(LearnedLDAF,t(X)))) ;

Details

Powered by Google Project Hosting