Skip to content

Instantly share code, notes, and snippets.

@wphicks
Last active January 19, 2021 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wphicks/199d75e91453257cd1ce6e2f45fe8cb5 to your computer and use it in GitHub Desktop.
Save wphicks/199d75e91453257cd1ce6e2f45fe8cb5 to your computer and use it in GitHub Desktop.
Benchmarking script for cuML RF->FIL conversion
from time import perf_counter
from cuml import using_output_type
from cuml.datasets import make_classification
from cuml.ensemble import RandomForestClassifier
from cuml.metrics import accuracy_score
with using_output_type('cupy'):
data, labels = make_classification(
n_samples=int(1e5),
n_features=20,
n_informative=18,
n_classes=2,
random_state=0
)
n_trees = 300
classifier = RandomForestClassifier(n_estimators=n_trees)
classifier.fit(data, labels)
# start = perf_counter()
preds = classifier.predict(data)
# runtime = perf_counter() - start
print(accuracy_score(preds, labels))
# print(f"Run 1: {runtime}")
#
# start = perf_counter()
# classifier.predict(data)
# runtime = perf_counter() - start
# print(f"Run 2: {runtime}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment