| Toolsklearn | R Documentation |
R6 class of the scikit-learn tool
An R6 class object.
Toolsklearn is a wrapper class for the precision-recall curve
calculation of
scikit-learn,
which is a machine learning library for Python.
The calculation is performed by a standalone Python module that is bundled
with prcbench and derived from the scikit-learn source code. As a
result, scikit-learn itself is not required, but reticulate,
a working Python installation, and numpy are. The tool can be
created without them, whereas the actual calculation cannot be performed.
In that case the tool returns a flat dummy curve instead of raising an
error, in the same way as ToolAUCCalculator does without
rJava, so that the predefined tool sets keep working on a machine
without Python.
Initialising Python imports numpy, and the BLAS library behind
numpy starts a thread pool sized to the number of cores. Those
threads cost CPU time that the import itself never spends, so the pool is
capped to two threads while the import runs. Set OMP_NUM_THREADS,
OPENBLAS_NUM_THREADS, MKL_NUM_THREADS, or
NUMEXPR_NUM_THREADS before the first tool is created to choose the
size of the pool instead.
Two AUC calculation methods are available. aucType = 1 uses average
precision, which is the summary scikit-learn recommends for
precision-recall curves, whereas aucType = 2 uses the trapezoidal
rule. The scikit-learn documentation discourages the use of the
trapezoidal rule for precision-recall curves.
Timings of this tool are not comparable with those of the tools written in
R. Every call crosses the R/Python boundary and converts the input and
output vectors, and run_benchmark counts that overhead as
part of the measurement. On a small test set it often dominates the curve
calculation itself. The accuracy evaluation of
run_evalcurve is unaffected.
ToolIFBase -> Toolsklearn
Toolsklearn$new()Default class initialization method.
Toolsklearn$new(...)
...set value for drop_intermediate, aucType.
Toolsklearn$set_drop_intermediate()A Boolean value to specify whether suboptimal thresholds are dropped.
Toolsklearn$set_drop_intermediate(val)
valTRUE: drop, FALSE: keep.
Toolsklearn$set_aucType()Set the AUC calculation method
Toolsklearn$set_aucType(val)
val1: average precision, 2: trapezoidal rule
Toolsklearn$clone()The objects of this class are cloneable with this method.
Toolsklearn$clone(deep = FALSE)
deepWhether to make a deep clone.
This class is derived from ToolIFBase.
create_toolset for creating a list of tools.
## Initialization
toolsklearn <- Toolsklearn$new()
## Show object info
toolsklearn
## create_toolset should be used for benchmarking and curve evaluation
toolsklearn2 <- create_toolset("sklearn")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.