splitData: The Data Spliting Function

Description Usage Arguments Details Value Examples

View source: R/gradDescentR.SupportFunctions.R

Description

A function to split dataset into training and testing data

Usage

1
splitData(dataSet, dataTrainRate = 0.5, seed = NULL)

Arguments

dataSet

a data.frame that representing dataset (m \times n), where m is the number of instances and n is the number of variables where the last column is the output variable. dataSet must have at least two columns and ten rows of data that contain only numbers (integer or float).

dataTrainRate

a float number between 0 to 1 representing the training data rate of given dataset. This parameter has default value of 0.5.

seed

a integer value for static random. Default value is NULL, which means the function will not do static random.

Details

This function split dataset into training and testing data. By default, this function split dataset into 50 dataTest. You can decide the training data rate by change the value of dataTrainRate. Example, if you want to set the training data rate by 80 As the remaining of dataTrainRate value, which is 0.2, will be set as dataTest rate.

Value

a list contains data.frame of training data and testing data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
##################################
## Splitting Dataset into Training and Testing Data
## load R Package data
data(gradDescentRData)
## get z-factor data
dataSet <- gradDescentRData$CompressilbilityFactor
## split dataset
splitedDataSet <- splitData(dataSet)
#show result
print(splitedDataSet$dataTrain)
print(splitedDataSet$dataTest)

computer-science-upi/gradDescent documentation built on May 29, 2019, 4:46 a.m.