Created
March 6, 2024 17:55
-
-
Save quantra-go-algo/aa9547e726f5adb0d0f3a71d12e35d86 to your computer and use it in GitHub Desktop.
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
# 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