Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: xgboost gpu accelerate #359

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
"""Define and train the model. Merge feature_select"""
X_train = select(X_train)

xgb_estimator = xgb.XGBRegressor(n_estimators=500, random_state=0, objective="reg:squarederror")
xgb_estimator = xgb.XGBRegressor(
n_estimators=500, random_state=0, objective="reg:squarederror", tree_method="gpu_hist", device="cuda"
)

model = MultiOutputRegressor(xgb_estimator, n_jobs=2)
model = MultiOutputRegressor(xgb_estimator, n_jobs=-1)

if is_sparse_df(X_train):
X_train = X_train.sparse.to_coo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
"objective": "multi:softmax", # Use softmax for multi-class classification
"num_class": len(set(y_train)), # Number of classes
"nthread": -1,
"tree_method": "gpu_hist",
"device": "cuda",
}
num_round = 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
params = {
"objective": "reg:squarederror", # Use squared error for regression
"nthread": -1,
"tree_method": "gpu_hist",
"device": "cuda",
}
num_round = 200

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
params = {
"objective": "multi:softprob",
"num_class": num_classes,
"nthred": -1,
"nthread": -1,
"tree_method": "gpu_hist",
"device": "cuda",
}
num_round = 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
# TODO: for quick running....
params = {
"nthread": -1,
"tree_method": "gpu_hist",
"device": "cuda",
}
num_round = 180

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
params = {
"objective": "reg:squarederror", # Use squared error for regression
"nthread": -1,
"tree_method": "gpu_hist",
"device": "cuda",
}
num_round = 200
num_round = 10

evallist = [(dtrain, "train"), (dvalid, "eval")]
bst = xgb.train(params, dtrain, num_round, evallist)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
params = {
"objective": "multi:softprob",
"num_class": num_classes,
"nthred": -1,
"nthread": -1,
"tree_method": "hist",
"device": "cuda",
}
num_round = 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def fit(X_train: pd.DataFrame, y_train: pd.DataFrame, X_valid: pd.DataFrame, y_v
# TODO: for quick running....
params = {
"nthread": -1,
"tree_method": "gpu_hist",
"device": "cuda",
}
num_round = 100

Expand Down