Classification Scores differ between H2O4GPU and Scikit-Learn

202 Views Asked by At

I've begun evaluating a random forest classifier using precision and recall. However, despite the train and test sets being identical for the CPU and GPU implementations of the classifier, I'm seeing differences in the returned evaluation scores. Is this a known bug within the library by chance?

Both code samples are below for reference.

Scikit-Learn (CPU)

from sklearn.metrics import recall_score, precision_score
from sklearn.ensemble import RandomForestClassifier

rf_cpu = RandomForestClassifier(n_estimators=5000, n_jobs=-1)
rf_cpu.fit(X_train, y_train)
rf_cpu_pred = clf.predict(X_test)

recall_score(rf_cpu_pred, y_test)
precision_score(rf_cpu_pred, y_test)

CPU Recall: 0.807186
CPU Precision: 0.82095

H2O4GPU (GPU)

from h2o4gpu.metrics import recall_score, precision_score
from h2o4gpu import RandomForestClassifier

rf_gpu = RandomForestClassifier(n_estimators=5000, n_gpus=1)
rf_gpu.fit(X_train, y_train)
rf_gpu_pred = clf.predict(X_test)

recall_score(rf_gpu_pred, y_test)
precision_score(rf_gpu_pred, y_test)

GPU Recall: 0.714286
GPU Precision: 0.809988
1

There are 1 best solutions below

3
On

Correction: Realized the inputs for precision and recall were in the wrong order. The order is always (y_true, y_pred), per the Scikit-Learn documentation.

Corrected Evaluation Code

recall_score(y_test, rf_gpu_pred)
precision_score(y_test, rf_gpu_pred)