Galileo
Search
⌃K

XGBoost

Logging Model Outputs

Logging an XGBoost model to Galileo involves 3 simple steps:
  1. 1.
    Use dq.set_labels_for_run to log class names.
  2. 2.
    After training an xgboost.XGBClassifier model, use dq.log_xgboost to log model predictions.
  3. 3.
    Call dq.finish to process the logged data. You'll get a link to the Galileo console when it's ready.
XGBoost
import dataquality as dq
from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
import xgboost as xgb
​
# 🔭🌕 Galileo login and run creation
dq.init(task_type="structured_classification",
project_name="structured_classification_xgboost",
run_name=f"example_run_tabular_xgb_01")
​
# Fetch a dataset from OpenML
bunch = fetch_openml("adult", as_frame=True)
X = bunch.data # pd.DataFrame
​
# Convert target series to numeric type for XGBoost training
y_categorical = bunch.target # pd.Series, Categorical data type
y = y_categorical.cat.codes.values # np.ndarray, integer data type
target_names = y_categorical.cat.categories.tolist() # list of string names
​
# Construct train and test splits
X_train, X_test, y_train, y_test = train_test_split(X, y)
​
# 🔭🌕 Galileo logging
dq.set_labels_for_run(target_names)
​
model = xgb.XGBoostClassifier(
# ...add your hyperparameters here...
)
model.fit(X_train, y_train)
​
# 🔭🌕 Galileo logging
dq.log_xgboost(model, split='training', X=X_train, y=y_train)
dq.log_xgboost(model, split='test', X=X_test, y=y_test)
​
dq.finish() # 🔭🌕 This will wait until the run is processed by Galileo

Example notebooks