pythonintermediate

Xgboost Advanced

Data science technique: xgboost-advanced

python
import xgboost as xgb
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
model = xgb.XGBClassifier(n_estimators=100, max_depth=4, random_state=42)
model.fit(X_train, y_train)
print(round(model.score(X_test, y_test), 4))

Use Cases

  • machine learning
  • data analysis

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.