getVariant: Obtain the learner associated with an identifier within a...

Description Usage Arguments Details Value References See Also Examples

View source: R/experiments.R

Description

The goal of this function is to obtain the learner object corresponding to a certain provided identifier in the context of an experimental comparison. This function finds its use after you run an experimental comparison using the infrastructure provided by the experimentalComparison() function. This latter function returns an object that contains the results of the several alternative methods that you have decided to compare. Each of these methods has an associated identifier (a string). This function allows you to obtain the learner object (which gives you access to several information necessary to run the associated algorithm), corresponding to its identifier.

Usage

1
getVariant(var, ExpsData)

Arguments

var

This is the string that identifies the learner you which to "extract".

ExpsData

This is a compExp object (type "class?compExp" for details) that contains the results of an experimental comparison obtained through the experimentalComparison() function.

Details

Most results analysis functions of the experimental infrastructure provided by the DMwR package use the identifiers generated either by calls to the variants function or names given by the user. Each of these names is associated with a concrete learning algorithm implemented by a R function and also to a set of parameter settings of this function. The function getVariant allows you to obtain all this information, in the form of a learner object, which is associated to an identifier within a compExp object.

Value

The result of this function is an object of class learner (type "class?learner" for details).

References

Torgo, L. (2010) Data Mining using R: learning with case studies, CRC Press (ISBN: 9781439810187).

http://www.dcc.fc.up.pt/~ltorgo/DataMiningWithR

See Also

variants, experimentalComparison

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Estimating several evaluation metrics on different variants of a
## regression tree on  a data set, using one repetition of 10-fold CV
data(swiss)

## First the user defined functions 
cv.rpartXse <- function(form, train, test, ...) {
    require(DMwR)
    t <- rpartXse(form, train, ...)
    p <- predict(t, test)
    mse <- mean((p - resp(form, test))^2)
    c(nmse = mse/mean((mean(resp(form, train)) - resp(form, test))^2), 
        mse = mse)
}

results <- experimentalComparison(
               c(dataset(Infant.Mortality ~ ., swiss)),
               c(variants('cv.rpartXse',se=c(0,0.5,1))),
               cvSettings(1,10,1234)
                                 )
## Get the best scores
bestScores(results)

# Obtain the settings corresponding to one of the variants
getVariant('cv.rpartXse.v1',results)

# Obtain the settings of the learner that got the best NMSE score on the
# swiss data set
getVariant(bestScores(results)$swiss['nmse','system'],results)

DMwR documentation built on May 1, 2019, 9:17 p.m.