Guest User

Untitled

a guest
Jan 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. source('load_data.R')
  2. d = read_and_preprocess_data_file('data/BADS_WS1718_known.csv')
  3. d = subset(d, select = -c(delivery_date)) # remove NAs
  4.  
  5. classdata = read_and_preprocess_data_file('data/BADS_WS1718_class.csv')
  6. classdata = subset(classdata, select = -c(delivery_date)) # remove NAs
  7.  
  8. # train the final model with 632 bootstrapping
  9. for (iter in 1:400) {
  10. # sample with replacement here - to understand why please refer to the book
  11. sampled_order_ids = sample(nrow(d), replace = TRUE)
  12. sampled_order_ids = unique(sampled_order_ids)
  13.  
  14. training_set = d[sampled_order_ids,]
  15. test_set = d[-sampled_order_ids,]
  16.  
  17. probs = append(probs, nrow(training_set)/nrow(d))
  18.  
  19. # train the model here with the training set, be sure to always train the same model,
  20. # and not discard and continuously start at 0
  21. # test the model accuracy with the test set and
  22. # append it to the log
  23. accs = append(accs, accuracy)
  24. }
  25.  
  26. # plot accuracies to see change with higher number of iterations
  27. plot(x=1:length(accs), y=accs, type='p')
Add Comment
Please, Sign In to add comment