TrainTestSplit
Description
The td_train_test_split_sqle()
function simulates how a model would
perform on new data. The function divides the dataset into
train and test subsets to evaluate machine learning algorithms
and validate processes. The first subset is used to train
the model. The second subset is used to make predictions and
compare the predictions to actual values.
Notes:
The
td_train_test_split_sqle()
function gives consistent results across multiple runs on same machine. With different machines, it might produce different train and test datasets.Requires the UTF8 client character set for UNICODE data.
Does not support Pass Through Characters (PTCs).
Does not support KanjiSJIS or graphic data types.
Usage
td_train_test_split_sqle (
data = NULL,
id.column = NULL,
stratify.column = NULL,
seed = NULL,
train.size = 0.75,
test.size = 0.25,
...
)
Arguments
data |
Required Argument. |
id.column |
Optional Argument.
Types: character |
stratify.column |
Optional Argument. |
seed |
Optional Argument.
Types: integer |
train.size |
Optional Argument.
Default Value: 0.75 |
test.size |
Optional Argument.
Default Value: 0.25 |
... |
Specifies the generic keyword arguments SQLE functions accept. Below
are the generic keyword arguments: volatile: Function allows the user to partition, hash, order or local order the input data. These generic arguments are available for each argument that accepts tbl_teradata as input and can be accessed as:
Note: |
Value
Function returns an object of class "td_train_test_split_sqle"
which is a named list containing object of class "tbl_teradata".
Named list member(s) can be referenced directly with the "$" operator
using the name(s):result
Examples
# Get the current context/connection.
con <- td_get_context()$connection
# Load the example data.
loadExampleData("tdplyr_example", "titanic")
# Create tbl_teradata object.
data_input <- tbl(con, "titanic")
# Check the list of available analytic functions.
display_analytic_functions()
# Example 1 : Split the input data to test dataset and train dataset,
# with ratio of test:train is 20:80. Note that output
# of td_train_test_split_sqle() function contains 'TD_IsTrainRow'
# column in which '0' represent test data and '1'
# represent train data.
TrainTestSplit_out <- td_train_test_split_sqle(
data = data_input,
id.column="passenger",
train.size=0.80,
test.size=0.20,
seed=42)
# Print the result.
print(TrainTestSplit_out$result)