Skip to content

Instantly share code, notes, and snippets.

View TanayGahlot's full-sized avatar

Tanay Gahlot TanayGahlot

View GitHub Profile
@TanayGahlot
TanayGahlot / gist:9622289
Last active August 29, 2015 13:57
errorHandling
if path is None:
# use an intelligent guess if it's not defined
def_path = op.realpath(op.join(op.dirname(__file__),
'..', '..', 'examples'))
path=''
#path = get_config(key, def_path)
# use the same for all datasets
if not os.path.exists(path):
try:
os.mkdir(def_path)
@TanayGahlot
TanayGahlot / parallelize_sklearn_inference.py
Created July 20, 2018 03:38
Answer to how to parallelize inference in sklearn using Python's multiprocessing?
from multiprocessing import Process, Pool, Queue
from time import sleep
class Predictor(Process):
"""it wraps your prediction object."""
def __init__(self, args, model_filepath):
"""intialize the super class and load the model from the pickle file."""
# intialize the super class.
super(Predictor, self).__init__(args=args)