Skip to content

Instantly share code, notes, and snippets.

View svenvanhal's full-sized avatar
👨‍💻
Software Engineering

Sven van Hal svenvanhal

👨‍💻
Software Engineering
  • The Netherlands
View GitHub Profile
import time
from isotree import IsolationForest as IsoTreeIsolationForest
from sklearn.datasets import make_classification
from sklearn.ensemble import IsolationForest as ScikitLearnIsolationForest
from sklearn.model_selection import train_test_split
def isotree_test(X1, X2, params):
iso = IsoTreeIsolationForest(ntrees=25, nthreads=-1, random_seed=259, **params)
@svenvanhal
svenvanhal / parallel_iforest_predict.py
Last active November 16, 2020 16:02
Parallel predict / score_samples for Scikit-Learn IsolationForest benchmark. Parallelizes the scoring function across multiple processes for a significant speed-up on multicore machines, as by default only a single core is used.
from multiprocessing import Pool
from os import sched_getaffinity
from timeit import timeit
import numpy as np
from joblib import Parallel, delayed
from sklearn.datasets import make_classification
from sklearn.ensemble import IsolationForest