<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 This notebook walks through a basic example of using the GPU-accelerated estimators from RAPIDS cuML and DMLC/XGBoost with TPOT for classification tasks. You must have access to an NVIDIA GPU and have cuML installed in your environment. Running this notebook without cuML will cause TPOT to raise a ValueError, indicating you should install cuML.
It is intended to show how the TPOT cuML configuration can provide significant performance benefits on medium-sized and larger datasets. 
Downloading Data
This example uses the Higgs Boson dataset from the UC Irvine Machine Learning Repository.
Step1:  Running TPOTClassifier
In the interest of time, we'll only use a 500,000 row sample of this file. 500,000 rows is more than enough for this example.
Step2:  Note that for cuML to work correctly, you must set n_jobs=1 (the default setting).
<ASSISTANT_TASK:>
Python Code:
import os
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from tpot import TPOTClassifier
# This is a 2.7 GB file.
# Please make sure you have enough space available before
# uncommenting the code below and downloading this file.
DATA_DIRECTORY = "./"
DATASET_PATH = os.path.join(DATA_DIRECTORY, "HIGGS.csv.gz")
# if not os.path.isfile(DATASET_PATH):
#     !wget https://archive.ics.uci.edu/ml/machine-learning-databases/00280/HIGGS.csv.gz -P {DATA_DIRECTORY}
# This fuction is borrowed and adapted from
# https://github.com/NVIDIA/gbm-bench/blob/master/datasets.py
# Thanks!
def prepare_higgs(nrows=None):
    higgs = pd.read_csv(DATASET_PATH, nrows=nrows)
    X = higgs.iloc[:, 1:].to_numpy(dtype=np.float32)
    y = higgs.iloc[:, 0].to_numpy(dtype=np.int64)
    return train_test_split(X, y, stratify=y, random_state=77, test_size=0.2)
Explanation: This notebook walks through a basic example of using the GPU-accelerated estimators from RAPIDS cuML and DMLC/XGBoost with TPOT for classification tasks. You must have access to an NVIDIA GPU and have cuML installed in your environment. Running this notebook without cuML will cause TPOT to raise a ValueError, indicating you should install cuML.
It is intended to show how the TPOT cuML configuration can provide significant performance benefits on medium-sized and larger datasets. 
Downloading Data
This example uses the Higgs Boson dataset from the UC Irvine Machine Learning Repository.
End of explanation
NROWS = 500_000
X_train, X_test, y_train, y_test = prepare_higgs(nrows=NROWS)
Explanation: Running TPOTClassifier
In the interest of time, we'll only use a 500,000 row sample of this file. 500,000 rows is more than enough for this example.
End of explanation
%%time
# cuML TPOT setup
SEED = 12
GENERATIONS = 10
POP_SIZE = 10
CV = 2
tpot = TPOTClassifier(
    generations=GENERATIONS,
    population_size=POP_SIZE,
    random_state=SEED,
    config_dict="TPOT cuML",
    n_jobs=1, # cuML requires n_jobs=1, the default
    cv=CV,
    verbosity=2,
)
tpot.fit(X_train, y_train)
%%time
preds = tpot.predict(X_test)
print(accuracy_score(y_test, preds))
%%time
# Default TPOT setup with same params
tpot = TPOTClassifier(
    generations=GENERATIONS,
    population_size=POP_SIZE,
    random_state=SEED,
    n_jobs=-1,
    cv=CV,
    verbosity=2,
)
tpot.fit(X_train, y_train)
%%time
preds = tpot.predict(X_test)
print(accuracy_score(y_test, preds))
Explanation: Note that for cuML to work correctly, you must set n_jobs=1 (the default setting).
End of explanation
<END_TASK>