Last active
January 19, 2021 16:48
-
-
Save wphicks/199d75e91453257cd1ce6e2f45fe8cb5 to your computer and use it in GitHub Desktop.
Benchmarking script for cuML RF->FIL conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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