Skip to content

Instantly share code, notes, and snippets.

@monogenea
Last active April 6, 2020 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monogenea/ca810670c01ceb9b6a249b4c6288b621 to your computer and use it in GitHub Desktop.
Save monogenea/ca810670c01ceb9b6a249b4c6288b621 to your computer and use it in GitHub Desktop.
# Define targets and augment data
target <- model.matrix(~0+species)
targetTrain <- do.call("rbind", lapply(1:(dim(Xtrain)[1]/length(fnamesTrain)),
function(x) target[-c(valIdx, testIdx),]))
targetVal <- do.call("rbind", lapply(1:(dim(Xval)[1]/length(fnamesVal)),
function(x) target[valIdx,]))
targetTest <- do.call("rbind", lapply(1:(dim(Xtest)[1]/length(fnamesTest)),
function(x) target[testIdx,]))
# Assemble Xs and Ys
train <- list(X = Xtrain, Y = targetTrain)
val <- list(X = Xval, Y = targetVal)
test <- list(X = Xtest, Y = targetTest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment