Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# KPMS-IT4I-EX
Companion to KPMS-IT4I with exercises. It is separate, to avoid lecture pdf replication on IT4I systems.

# ASwR
15 changes: 15 additions & 0 deletions code/UKOL5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#PBS -N rf
#PBS -l select=1:ncpus=128,walltime=00:05:00
#PBS -q qexp
#PBS -e UKOL5.e
#PBS -o UKOL5.o

cd ~/KPMS-IT4I-EX-1/code
pwd

module load R
echo "loaded R"


time Rscript UKOL5_simulace.r 128
8 changes: 4 additions & 4 deletions code/rf_cv_karolina_pbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#PBS -e rf_cv.e
#PBS -o rf_cv.o

cd ~/KPMS-IT4I-EX/code
cd ~/KPMS-IT4I-EX-1/code
pwd

module load R
echo "loaded R"

time Rscript rf_cv_serial.r
time Rscript rf_cv_mc.r 8
time Rscript rf_cv_mc.r 16
#time Rscript rf_cv_serial.r
#time Rscript rf_cv_mc.r 8
#time Rscript rf_cv_mc.r 16
time Rscript rf_cv_mc.r 32
time Rscript rf_cv_mc.r 64
time Rscript rf_cv_mc.r 128
12 changes: 6 additions & 6 deletions code/rf_cv_mc.r
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ fold_err = function(i, cv_pars, folds, train) {
nc = as.numeric(commandArgs(TRUE)[1])
cat("Running with", nc, "cores\n")
system.time({
cv_err = parallel::mclapply(1:nrow(cv_pars), fold_err, cv_pars, folds = folds,
cv_err = parallel::mclapply(1:nrow(cv_pars), fold_err, cv_pars, folds = folds,
train = train, mc.cores = nc)
err = tapply(unlist(cv_err), cv_pars[, "mtry"], sum)
err = tapply(unlist(cv_err), cv_pars[, "mtry"], sum)
})
pdf(paste0("rf_cv_mc", nc, ".pdf")); plot(mtry_val, err/(n - n_test)); dev.off()

rf.all = randomForest(lettr ~ ., train, ntree = ntree)
pred = predict(rf.all, test)
correct = sum(pred == test$lettr)
ntree_new = lapply(splitIndices(200, nc), length)
rf = function(x) randomForest(lettr ~ ., train, ntree=x, norm.votes = FALSE)
rf.out = mclapply(ntree_new, rf, mc.cores = nc)
rf.all = do.call(combine, rf.out)

mtry = mtry_val[which.min(err)]
rf.all = randomForest(lettr ~ ., train, ntree = ntree, mtry = mtry)
pred_cv = predict(rf.all, test)
correct_cv = sum(pred_cv == test$lettr)
cat("Proportion Correct: ", correct/n_test, "(mtry = ", floor((ncol(test) - 1)/3),
") with cv:", correct_cv/n_test, "(mtry = ", mtry, ")\n", sep = "")