Skip to content

Instantly share code, notes, and snippets.

const _ = require('underscore');
const { Client } = require('pg');
const all_query = `SELECT id FROM "filter-test"."filter-test";`;
const some_query = `SELECT id, blob FROM "filter-test"."filter-test" WHERE id IN ('$(WHERE_IN_FILTER)');`;
async function query(q) {
const client = new Client({
user: 'postgres',
database: 'postgres'
@thomasjungblut
thomasjungblut / gist:fe9102e5a1592f8ba1a95c53345016c7
Created November 4, 2021 15:47
monty hall problem with monte carlo
#!/usr/bin/python3
import random as r
def random_doors():
doors = [False] * 3
doors[r.randint(0, 2)] = True
return doors
#!/usr/bin/python3
from time import sleep
import requests
from twilio.rest import Client
TWILIO_ACCOUNT_SID = "ACXXX"
TWILIO_AUTH_TOKEN = "XXX"
FROM = "+1XXXXX"
RECIPIENT = "+491XXXX"
@thomasjungblut
thomasjungblut / xgb_bayes_opt_cv.py
Last active May 22, 2024 22:14
XGBoost hyper parameter optimization using bayes_opt
from bayes_opt import BayesianOptimization
from sklearn.cross_validation import KFold
import xgboost as xgb
def xgbCv(train, features, numRounds, eta, gamma, maxDepth, minChildWeight, subsample, colSample):
# prepare xgb parameters
params = {
"objective": "reg:linear",
"booster" : "gbtree",
"eval_metric": "mae",
public class FlatMapTest {
public FlatMapTest() { // <init> //()V
<localVar:index=0 , name=this , desc=LFlatMapTest;, sig=null, start=L1, end=L2>
L1 {
aload0 // reference to self
invokespecial java/lang/Object <init>(()V);
return
}
@thomasjungblut
thomasjungblut / gist.R
Last active November 14, 2019 04:57
XGBoost Validation and Early Stopping in R
train <- read.csv("train.csv")
bound <- floor(nrow(train) * 0.9)
train <- train[sample(nrow(train)), ]
df.train <- train[1:bound, ]
df.validation <- train[(bound+1):nrow(train), ]
train.y <- df.train$TARGET
validation.y <- df.validation$TARGET
dtrain <- xgb.DMatrix(data=df.train, label=train.y)
@thomasjungblut
thomasjungblut / gist:624ba7b7f4dc6246659c
Created June 17, 2015 20:09
numerical gradients with fmincg
import de.jungblut.math.DoubleVector;
import de.jungblut.math.MathUtils;
import de.jungblut.math.dense.DenseDoubleVector;
import de.jungblut.math.minimize.CostFunction;
import de.jungblut.math.minimize.CostGradientTuple;
import de.jungblut.math.minimize.Fmincg;
public class FminCGNumericalGradient {
static class RealCostFunction implements CostFunction {
@thomasjungblut
thomasjungblut / gist:e4759797f5a52d78e06d
Last active August 29, 2015 14:16
MinHashing Example
package de.jungblut.nlp;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.google.common.base.Stopwatch;
@thomasjungblut
thomasjungblut / gist:fdf458587463a993d173
Created February 7, 2015 20:47
PiEstimator (multithreaded monte carlo)
import java.util.concurrent.Executors
import scala.util.Random
import java.util.concurrent.ExecutorService
import java.util.concurrent.Callable
import java.util.concurrent.FutureTask
import java.util.concurrent.ExecutorCompletionService
import scala.collection.mutable.MutableList
object PiEstimator extends App {
@thomasjungblut
thomasjungblut / BinaryTree.java
Last active August 29, 2015 14:02
findKthSmallestValue in a Binary Tree.
package de.jungblut.interviews;
import java.util.Stack;
import com.google.common.base.Preconditions;
public class BinaryTree {
class TreeNode {
TreeNode left;