% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/LearnerClassif.R
\name{LearnerClassif}
\alias{LearnerClassif}
\title{Classification Learner}
\description{
This Learner specializes \link{Learner} for classification problems:
\itemize{
\item \code{task_type} is set to \code{"classif"}.
\item Creates \link{Prediction}s of class \link{PredictionClassif}.
\item Possible values for \code{predict_types} are:
\itemize{
\item \code{"response"}: Predicts a class label for each observation in the test set.
\item \code{"prob"}: Predicts the posterior probability for each class for each observation in the test set.
}
\item Additional learner properties include:
\itemize{
\item \code{"twoclass"}: The learner works on binary classification problems.
\item \code{"multiclass"}: The learner works on multiclass classification problems.
}
}

Predefined learners can be found in the \link[mlr3misc:Dictionary]{dictionary} \link{mlr_learners}.
Essential classification learners can be found in this dictionary after loading \CRANpkg{mlr3learners}.
Additional learners are implemented in the Github package \url{https://github.com/mlr-org/mlr3extralearners}.
}
\examples{
# get all classification learners from mlr_learners:
lrns = mlr_learners$mget(mlr_learners$keys("^classif"))
names(lrns)

# get a specific learner from mlr_learners:
lrn = lrn("classif.rpart")
print(lrn)

# train the learner:
task = tsk("penguins")
lrn$train(task, 1:200)

# predict on new observations:
lrn$predict(task, 201:344)$confusion
}
\seealso{
\itemize{
\item Chapter in the \href{https://mlr3book.mlr-org.com/}{mlr3book}:
\url{https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html#sec-learners}
\item Package \CRANpkg{mlr3learners} for a solid collection of essential learners.
\item Package \href{https://github.com/mlr-org/mlr3extralearners}{mlr3extralearners} for more learners.
\item \link[mlr3misc:Dictionary]{Dictionary} of \link[=Learner]{Learners}: \link{mlr_learners}
\item \code{as.data.table(mlr_learners)} for a table of available \link[=Learner]{Learners} in the running session (depending on the loaded packages).
\item \CRANpkg{mlr3pipelines} to combine learners with pre- and postprocessing steps.
\item Package \CRANpkg{mlr3viz} for some generic visualizations.
\item Extension packages for additional task types:
\itemize{
\item \CRANpkg{mlr3proba} for probabilistic supervised regression and survival analysis.
\item \CRANpkg{mlr3cluster} for unsupervised clustering.
}
\item \CRANpkg{mlr3tuning} for tuning of hyperparameters, \CRANpkg{mlr3tuningspaces}
for established default tuning spaces.
}

Other Learner:
\code{\link{Learner}},
\code{\link{LearnerRegr}},
\code{\link{mlr_learners}},
\code{\link{mlr_learners_classif.debug}},
\code{\link{mlr_learners_classif.featureless}},
\code{\link{mlr_learners_classif.rpart}},
\code{\link{mlr_learners_regr.debug}},
\code{\link{mlr_learners_regr.featureless}},
\code{\link{mlr_learners_regr.rpart}}
}
\concept{Learner}
\section{Super class}{
\code{\link[mlr3:Learner]{Learner}} -> \code{LearnerClassif}
}
\section{Methods}{
\subsection{Public methods}{
  \itemize{
    \item \href{#method-LearnerClassif-initialize}{\code{LearnerClassif$new()}}
    \item \href{#method-LearnerClassif-predict_newdata_fast}{\code{LearnerClassif$predict_newdata_fast()}}
    \item \href{#method-LearnerClassif-clone}{\code{LearnerClassif$clone()}}
  }
}
\if{html}{\out{<details><summary>Inherited methods</summary>
<ul>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="base_learner"><a href='../../mlr3/html/Learner.html#method-Learner-base_learner'><code>Learner$base_learner()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="configure"><a href='../../mlr3/html/Learner.html#method-Learner-configure'><code>Learner$configure()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="encapsulate"><a href='../../mlr3/html/Learner.html#method-Learner-encapsulate'><code>Learner$encapsulate()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="format"><a href='../../mlr3/html/Learner.html#method-Learner-format'><code>Learner$format()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="help"><a href='../../mlr3/html/Learner.html#method-Learner-help'><code>Learner$help()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="predict"><a href='../../mlr3/html/Learner.html#method-Learner-predict'><code>Learner$predict()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="predict_newdata"><a href='../../mlr3/html/Learner.html#method-Learner-predict_newdata'><code>Learner$predict_newdata()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="print"><a href='../../mlr3/html/Learner.html#method-Learner-print'><code>Learner$print()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="reset"><a href='../../mlr3/html/Learner.html#method-Learner-reset'><code>Learner$reset()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="selected_features"><a href='../../mlr3/html/Learner.html#method-Learner-selected_features'><code>Learner$selected_features()</code></a></span></li>
  <li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="train"><a href='../../mlr3/html/Learner.html#method-Learner-train'><code>Learner$train()</code></a></span></li>
</ul>
</details>}}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-LearnerClassif-initialize"></a>}}
\if{latex}{\out{\hypertarget{method-LearnerClassif-initialize}{}}}
\subsection{\code{LearnerClassif$new()}}{
  Creates a new instance of this \link[R6:R6Class]{R6} class.
  \subsection{Usage}{
    \if{html}{\out{<div class="r">}}
    \preformatted{LearnerClassif$new(
  id,
  task_type = "classif",
  param_set = ps(),
  predict_types = "response",
  feature_types = character(),
  properties = character(),
  packages = character(),
  label = NA_character_,
  man = NA_character_
)}
    \if{html}{\out{</div>}}
  }
  \subsection{Arguments}{
    \if{html}{\out{<div class="arguments">}}
    \describe{
      \item{\code{id}}{(\code{character(1)})\cr
Identifier for the new instance.}
      \item{\code{task_type}}{(\code{character(1)})\cr
Type of task, e.g. \code{"regr"} or \code{"classif"}.
Must be an element of \link[=mlr_reflections]{mlr_reflections$task_types$type}.}
      \item{\code{param_set}}{(\link[paradox:ParamSet]{paradox::ParamSet})\cr
Set of hyperparameters.}
      \item{\code{predict_types}}{(\code{character()})\cr
Supported predict types. Must be a subset of \code{\link[=mlr_reflections]{mlr_reflections$learner_predict_types}}.}
      \item{\code{feature_types}}{(\code{character()})\cr
Feature types the learner operates on. Must be a subset of \code{\link[=mlr_reflections]{mlr_reflections$task_feature_types}}.}
      \item{\code{properties}}{(\code{character()})\cr
Set of properties of the \link{Learner}.
Must be a subset of \code{\link[=mlr_reflections]{mlr_reflections$learner_properties}}.
The following properties are currently standardized and understood by learners in \CRANpkg{mlr3}:
\itemize{
\item \code{"missings"}: The learner can handle missing values in the data.
\item \code{"weights"}: The learner supports observation weights.
\item \code{"offset"}: The learner can incorporate offset values to adjust predictions.
\item \code{"importance"}: The learner supports extraction of importance scores, i.e. comes with an \verb{$importance()} extractor function (see section on optional extractors in \link{Learner}).
\item \code{"selected_features"}: The learner supports extraction of the set of selected features, i.e. comes with a \verb{$selected_features()} extractor function (see section on optional extractors in \link{Learner}).
\item \code{"oob_error"}: The learner supports extraction of estimated out of bag error, i.e. comes with a \code{oob_error()} extractor function (see section on optional extractors in \link{Learner}).
\item \code{"validation"}: The learner can use a validation task during training.
\item \code{"internal_tuning"}: The learner is able to internally optimize hyperparameters (those are also tagged with \code{"internal_tuning"}).
\item \code{"marshal"}: To save learners with this property, you need to call \verb{$marshal()} first.
If a learner is in a marshaled state, you call first need to call \verb{$unmarshal()} to use its model, e.g. for prediction.
\item \code{"hotstart_forward"}: The learner supports to hotstart a model forward.
\item \code{"hotstart_backward"}: The learner supports hotstarting a model backward.
\item `"featureless": The learner does not use features.
}}
      \item{\code{packages}}{(\code{character()})\cr
Set of required packages.
A warning is signaled by the constructor if at least one of the packages is not installed,
but loaded (not attached) later on-demand via \code{\link[=requireNamespace]{requireNamespace()}}.}
      \item{\code{label}}{(\code{character(1)})\cr
Label for the new instance.}
      \item{\code{man}}{(\code{character(1)})\cr
String in the format \verb{[pkg]::[topic]} pointing to a manual page for this object.
The referenced help package can be opened via method \verb{$help()}.}
    }
    \if{html}{\out{</div>}}
  }
}

\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-LearnerClassif-predict_newdata_fast"></a>}}
\if{latex}{\out{\hypertarget{method-LearnerClassif-predict_newdata_fast}{}}}
\subsection{\code{LearnerClassif$predict_newdata_fast()}}{
  Predicts outcomes for new data in \code{newdata} using the model fitted during \verb{$train()}.
This method is faster than \verb{$predict_newdata()} as it skips assertions,
type conversions, encapsulation, and logging.
The learner must be trained before calling this method.

Unlike \verb{$predict_newdata()}, this method does not return a \link{Prediction} object.
Instead, it returns a list with either a \code{"response"} or \code{"prob"} element, depending on the prediction type.

Note that \code{state$predict_time} and \code{state$log} will remain empty after using this method.
Some learners may not support this method and may fail when it is called.
Prefer \verb{$predict_newdata()} unless performance is critical.

If the model was trained via \code{\link[=resample]{resample()}} or \code{\link[=benchmark]{benchmark()}},
you must pass the associated task object stored in the corresponding \link{ResampleResult} or \link{BenchmarkResult}.
  \subsection{Usage}{
    \if{html}{\out{<div class="r">}}
    \preformatted{LearnerClassif$predict_newdata_fast(newdata, task = NULL)}
    \if{html}{\out{</div>}}
  }
  \subsection{Arguments}{
    \if{html}{\out{<div class="arguments">}}
    \describe{
      \item{\code{newdata}}{\code{\link[data.table:data.table]{data.table::data.table()}}\cr
New data to predict on.}
      \item{\code{task}}{(\link{Task}).}
    }
    \if{html}{\out{</div>}}
  }
  \subsection{Returns}{
    \code{list()} with elements \code{"response"} or \code{"prob"} depending on the predict type.
  }
}

\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-LearnerClassif-clone"></a>}}
\if{latex}{\out{\hypertarget{method-LearnerClassif-clone}{}}}
\subsection{\code{LearnerClassif$clone()}}{
  The objects of this class are cloneable with this method.
  \subsection{Usage}{
    \if{html}{\out{<div class="r">}}
    \preformatted{LearnerClassif$clone(deep = FALSE)}
    \if{html}{\out{</div>}}
  }
  \subsection{Arguments}{
    \if{html}{\out{<div class="arguments">}}
    \describe{
      \item{\code{deep}}{Whether to make a deep clone.}
    }
    \if{html}{\out{</div>}}
  }
}

}
