Description Usage Arguments Value See Also Examples
Convert data into training and test sets so that the training set contains approximately the specified ratio of all labels.
1 | Split2TrainTest(Y, X, train.ratio)
|
Y |
an n-by-1 vector of responses or labels. |
X |
an n-by-p design matrix of predictors. |
train.ratio |
a ratio of the size of the resulting training set to the size of data. |
A list of the following values:
the training set of Y.
the test set of Y.
the training set of X.
the test set of X.
CheckNonNumeric(), GetPrecision(), FetchBuddle(), MakeConfusionMatrix(), OneHot2Label(), TrainBuddle()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | data(iris)
Label = c("setosa", "versicolor", "virginica")
train.ratio=0.8
Y = iris$Species
X = cbind( iris$Sepal.Length, iris$Sepal.Width, iris$Petal.Length, iris$Petal.Width)
lst = Split2TrainTest(Y, X, train.ratio)
Ytrain = lst$y.train
Ytest = lst$y.test
length(Ytrain)
length(Ytest)
length(which(Ytrain==Label[1]))
length(which(Ytrain==Label[2]))
length(which(Ytrain==Label[3]))
length(which(Ytest==Label[1]))
length(which(Ytest==Label[2]))
length(which(Ytest==Label[3]))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.