Skip to content

Instantly share code, notes, and snippets.

View jakob-r's full-sized avatar

Jakob Richter jakob-r

View GitHub Profile
@jakob-r
jakob-r / waitAndSubmitExpired.R
Last active October 19, 2015 16:55
BatchJobs: Automaticly submit expired jobs
waitAndSubmitExpired = function(reg, resources, wait = 30, ...) {
done.ids = findDone(reg)
error.ids = findErrors(reg)
expired.ids = findExpired(reg)
submitted.ids = findSubmitted(reg)
restarted.ids = numeric()
while (!all(submitted.ids %in% c(done.ids, error.ids))) {
if (length(expired.ids) > 0)
submitJobs(reg, expired.ids, resources = resources, ...)
library(checkmate)
library(mlr)
makePersp3DLayer = function(opt.path.dt, par.set = NULL, learner, y = "y", x = NULL, resolution = 100, nrow.limit = 400) {
x = coalesce(x, getParamIds(par.set))
assertCharacter(x, len = 2)
data = opt.path.dt[, c(x,y), with=FALSE]
if (nrow(opt.path.dt) > nrow.limit) {
data = data[sample(nrow(data), size = nrow.limit),]
}
# Author: Jakob Richter (https://gist.github.com/jakob-r)
# colfuncMiddle does the same as colfunc but gives respect to middle point.
# usage: x : numeric()
# colfunc: function generated by colorRampPalette()
# zeropoint: numeric(1)
colfuncMiddle = function(x, colfunc, n, zeropoint=0){
stopifnot(is.numeric(x) | is.factor(x))
if(!missing(n)){
stopifnot(length(n)==1)