The R file available takes a data set and enforces monotonoicity between any number of the inputs and the output. At the moment it is set up for ordinal labels 1, 2, 3… however at some stage I’ll adapt it to the real valued case.

Although the relabeling is accomplished using a linear (binary objective) program, it can be quite time-heavy due to the need to construct a constraints matrix that has NxN rows. I made the mistake of using the Abalone dataset as a test subject (4177 instances).

**relabel()…**

relabel <- function(the.data,file.out="fileout.txt"
,stats.out = "statsout.txt",empLoss = L2loss)

The relabel function uses the method of Feelders, as well as writing the new monotone dataset, a stats file will also be created which specifies the number of labels, the cost of the relabeling (total L1 loss), the number of comparable pairs, monotone pairs (and percentages) etc.

**relabel2()**

relabel2 <- function(the.data,file.out="fileout2.txt"
,stats.out = "statsout2.txt")

relabel2 uses a different method of relabeling similar to the ordinal decomposition method. The iteration steps are essentially the same, however the objective function in the linear program only minimizes based on 0-1 labels – so in the first iteration, rather than calculate the cost of relabeling as 1 or 2 by the L1 or L2 loss to their observed label, it only cares about whether the label is 1 or higher. The upshot is the number of relabels will usually be less but the L1 loss will be higher.

**parto()**

parto <- function(x,y,mon.vars = 1:length(x)
,dec.vars = FALSE)

Both the above relabeling algorithms use the parto function in its default form (monotonicity between all the values is assumed). If this is not the case, the variables that are monotone can be specified e.g. c(1,2,3) and the variables that should have a monotone decreasing relationship can be specified e.g. c(4,6) and then when the parto function is used later, monotonicity will be based on the output of parto and whether *y*_i is less than *y*_j. It is no more difficult to enforce partial monotonicity than standard monotonicity.

relabel Rfile

### Like this:

Like Loading...

*Related*