Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Preparatory code for lasso regression lecture
# prep training and test datasets
trainRows <- createDataPartition(prostate$lpsa, p=.75, list=FALSE)
trainData <- prostate[trainRows, ]
testData <- prostate[-trainRows, ]
# prepare X and Y matrices separately
train_x <- as.matrix(trainData[, colnames(trainData) %ni% c("lpsa", "train")])
train_y <- as.matrix(trainData[, "lpsa"])
test_x <- as.matrix(testData[, colnames(trainData) %ni% c("lpsa", "train")])
test_y <- as.matrix(testData[, "lpsa"])
# grid
grid=10^seq(10, -2, length=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.