Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #Lectura de la DB
  2. MyData <- read.csv(file="C:/Users/56971/Desktop/Analisis de Datos/breast-cancer-wisconsin/breast-cancer-wisconsin/breast-cancer-wisconsin.csv", na.strings='?', header=TRUE, sep=",")
  3.  
  4. #Se eliminan las mediciones con datos NA
  5. cancer <- na.omit(MyData)
  6.  
  7. smp_siz <- floor(0.75*nrow(cancer)) # creates a value for dividing the data into train and test. In this case the value is defined as 75% of the number of rows in the dataset
  8.  
  9. set.seed(123)
  10.  
  11. train_ind = sample(seq_len(nrow(cancer)),size = smp_siz)
  12.  
  13. train =cancer[train_ind,]
  14. test=cancer[-train_ind,]
  15.  
  16. model <- naiveBayes(class ~., data = train)
  17.  
  18. results <- predict(model, newdata=test)
  19.  
  20. View(results)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement