Skip to content

Instantly share code, notes, and snippets.

@mfmakahiya
Created July 30, 2019 07:07
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 mfmakahiya/c2065015ca19b0dba5c4038949c85655 to your computer and use it in GitHub Desktop.
Save mfmakahiya/c2065015ca19b0dba5c4038949c85655 to your computer and use it in GitHub Desktop.
library(Matrix)
library(glmnet)
library(pROC)
library(caret)
# Import dataset
data1 = read.csv(file = "./data/input/breast-cancer.csv")
data1$diagnosis<-ifelse(data1$diagnosis=='M', 1,0)
data2 = data.matrix(data1)
Matrix(data2, sparse = TRUE)
set.seed(6789)
# Split the data to train and test
split = sample(nrow(data1), floor(0.7*nrow(data1)))
train = data1[split,]
test = data1[-split,]
train_sparse = sparse.model.matrix(~., train[,3:32])
test_sparse = sparse.model.matrix(~., test[,3:32])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment