R/Margin.vote.R

Defines functions Margin.vote

Documented in Margin.vote

Margin.vote <-
function(vote,type="unsupervised",observed)
{
         myDim<-dim(vote)
         n_classes<-myDim[1]
         n_instances<-myDim[2]
         myMargin<-rep(-99,n_instances)
    if(type=="unsupervised")
     {

         
         for( i in 1 : n_instances)
         {
              myMaxVote<-max(vote[,i])
              whichMax<-which.max(vote[,i])
              mySecVote<-max(vote[-whichMax,i])
              myMargin[i]<-myMaxVote-mySecVote
              
             
         }
         
     }
    else
      {
           for(i in 1 : n_instances)
            {
                  myLabelVote<-vote[observed[i],i]
                  myMaxvote<-max(vote[-observed[i],i])
                  myMargin[i]<-myLabelVote-myMaxvote
            }
      }

      return (myMargin)
}

Try the adabag package in your browser

Any scripts or data that you put into this service are public.

adabag documentation built on May 31, 2023, 9:09 p.m.