Skip to content

Instantly share code, notes, and snippets.

View christian-rauch's full-sized avatar

Christian Rauch christian-rauch

View GitHub Profile
@christian-rauch
christian-rauch / resize.py
Created January 25, 2017 18:48
resize image in parallel by sampling
#!/usr/bin/env python
import skimage.io as io
import warnings
import sys, os
import glob
from joblib import Parallel, delayed
import multiprocessing
@christian-rauch
christian-rauch / class_weights.py
Last active July 5, 2023 14:06
class weights by median frequency balancing
#!/usr/bin/env python
import sys, os
import glob
import numpy as np
import skimage.io as io
np.set_printoptions(precision=15)
files = glob.glob(os.path.join(sys.argv[1], "*.png"))
@christian-rauch
christian-rauch / prune_rf.py
Last active March 8, 2017 12:38
Prune (cut) scikit's RandomForestClassifier at a given depth
# This will insert leaf nodes at a given depth of the tree, e.g. the decision path will end at this depth.
# It does not actually remove the nodes from the list in 'children_left' and 'children_right',
# e.g. the split nodes will stay in the tree but will not be used within a decision path.
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree.tree import Tree
def prune_node(tree, node_id, parent_depth, prune_depth):
this_depth = parent_depth+1 # root node at depth 1
#!/bin/sh
sudo service ntp stop
sudo ntpdate -u pool.ntp.org
sudo service ntp start