Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Created March 6, 2024 17:55
Show Gist options
  • Save quantra-go-algo/aa9547e726f5adb0d0f3a71d12e35d86 to your computer and use it in GitHub Desktop.
Save quantra-go-algo/aa9547e726f5adb0d0f3a71d12e35d86 to your computer and use it in GitHub Desktop.
# Import the libraries
import pandas as pd
import cudf
import cuml
from cuml.datasets import make_classification
from cuml.model_selection import train_test_split
# Generating a sample Pandas DataFrame
X, y = make_classification(n_samples=1000, n_features=4, n_classes=2, random_state=42)
# Splitting the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Creating and fitting a Random Forest Classifier using cuML
rf_classifier = cuml.ensemble.RandomForestClassifier(n_estimators=100)
rf_classifier.fit(X_train, y_train)
# Predicting on the test set
y_pred = rf_classifier.predict(X_test)
# Displaying sample predictions
print("Sample predictions:")
print(y_pred[:10])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment