% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hardhat.R
\name{tabnet_pretrain}
\alias{tabnet_pretrain}
\alias{tabnet_pretrain.default}
\alias{tabnet_pretrain.data.frame}
\alias{tabnet_pretrain.formula}
\alias{tabnet_pretrain.recipe}
\alias{tabnet_pretrain.Node}
\title{Tabnet model}
\usage{
tabnet_pretrain(x, ...)

\method{tabnet_pretrain}{default}(x, ...)

\method{tabnet_pretrain}{data.frame}(
  x,
  y = NULL,
  tabnet_model = NULL,
  config = tabnet_config(),
  ...,
  from_epoch = NULL
)

\method{tabnet_pretrain}{formula}(
  formula,
  data,
  tabnet_model = NULL,
  config = tabnet_config(),
  ...,
  from_epoch = NULL
)

\method{tabnet_pretrain}{recipe}(
  x,
  data,
  tabnet_model = NULL,
  config = tabnet_config(),
  ...,
  from_epoch = NULL
)

\method{tabnet_pretrain}{Node}(
  x,
  tabnet_model = NULL,
  config = tabnet_config(),
  ...,
  from_epoch = NULL
)
}
\arguments{
\item{x}{Depending on the context:
\itemize{
\item A \strong{data frame} of predictors.
\item A \strong{matrix} of predictors.
\item A \strong{recipe} specifying a set of preprocessing steps
created from \code{\link[recipes:recipe]{recipes::recipe()}}.
\item A \strong{Node} where tree leaves will be left out,
and attributes will be used as predictors.
}

The predictor data should be standardized (e.g. centered or scaled).
The model treats categorical predictors internally thus, you don't need to
make any treatment.
The model treats missing values internally thus, you don't need to make any
treatment.}

\item{...}{Model hyperparameters.
Any hyperparameters set here will update those set by the config argument.
See \code{\link[=tabnet_config]{tabnet_config()}} for a list of all possible hyperparameters.}

\item{y}{(optional) When \code{x} is a \strong{data frame} or \strong{matrix}, \code{y} is the outcome}

\item{tabnet_model}{A pretrained \code{tabnet_model} object to continue the fitting on.
if \code{NULL} (the default) a brand new model is initialized.}

\item{config}{A set of hyperparameters created using the \code{tabnet_config} function.
If no argument is supplied, this will use the default values in \code{\link[=tabnet_config]{tabnet_config()}}.}

\item{from_epoch}{When a \code{tabnet_model} is provided, restore the network weights from a specific epoch.
Default is last available checkpoint for restored model, or last epoch for in-memory model.}

\item{formula}{A formula specifying the outcome terms on the left-hand side,
and the predictor terms on the right-hand side.}

\item{data}{When a \strong{recipe} or \strong{formula} is used, \code{data} is specified as:
\itemize{
\item A \strong{data frame} containing both the predictors and the outcome.
}}
}
\value{
A TabNet model object. It can be used for serialization, predictions, or further fitting.
}
\description{
Pretrain the \href{https://arxiv.org/abs/1908.07442}{TabNet: Attentive Interpretable Tabular Learning} model
on the predictor data exclusively (unsupervised training).
}
\section{outcome}{


Outcome value are accepted here only for consistent syntax with \code{tabnet_fit}, but
by design the outcome, if present, is ignored during pre-training.
}

\section{pre-training from a previous model}{


When providing a parent \code{tabnet_model} parameter, the model pretraining resumes from that model weights
at the following epoch:
\itemize{
\item last pretrained epoch for a model already in torch context
\item Last model checkpoint epoch for a model loaded from file
\item the epoch related to a checkpoint matching or preceding the \code{from_epoch} value if provided
The model pretraining metrics append on top of the parent metrics in the returned TabNet model.
}
}

\section{Threading}{


TabNet uses \code{torch} as its backend for computation and \code{torch} uses all
available threads by default.

You can control the number of threads used by \code{torch} with:

\if{html}{\out{<div class="sourceCode">}}\preformatted{torch::torch_set_num_threads(1)
torch::torch_set_num_interop_threads(1)
}\if{html}{\out{</div>}}
}

\examples{
\dontshow{if (torch::torch_is_installed()) withAutoprint(\{ # examplesIf}
data("ames", package = "modeldata")
pretrained <- tabnet_pretrain(Sale_Price ~ ., data = ames, epochs = 1)
\dontshow{\}) # examplesIf}
}
