CatBoost: Một thư viện boosting hiệu quả do Yandex phát triển, tốt cho dữ liệu chứa các đặc trưng...
CatBoost
from catboost import CatBoostClassifier
from sklearn.model_selection import train_test_split
import pandas as pd
# Dữ liệu mẫu với đặc trưng phân loại
df = pd.DataFrame({
'age': [25, 35, 45, 22],
'gender': ['M', 'F', 'M', 'F'],
'target': [1, 0, 1, 0]
})
# Tách dữ liệu
X = df[['age', 'gender']]
y = df['target']
cat_features = ['gender']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
# Mô hình CatBoost
model = CatBoostClassifier(verbose=0)
model.fit(X_train, y_train, cat_features=cat_features)
# Dự đoán
preds = model.predict(X_test)PreviousXGBoost & LightGBM: Tối ưu cho các bài toán về cây quyết định gradient boostingNextPhần 3: Học Sâu (Deep Learning)
Last updated
