UD4 · Validación de la calidad de los componentes | MP03
SVM y metodos de potenciacion (Boosting)
from sklearn.svm import SVC
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
import xgboost as xgb
pipeline_svm = Pipeline([
("scaler", StandardScaler()),
("svm", SVC(
C=10.0,
kernel="rbf",
gamma="scale",
class_weight="balanced",
probability=True,
random_state=42
))
])
pipeline_svm.fit(X_train, y_train)
xgb_model = xgb.XGBClassifier(
n_estimators=500,
learning_rate=0.05,
max_depth=5,
subsample=0.8,
colsample_bytree=0.8,
scale_pos_weight=len(y_train[y_train==0]) / len(y_train[y_train==1]),
use_label_encoder=False,
eval_metric="logloss",
random_state=42
)
xgb_model.fit(X_train, y_train, eval_set=[(X_val, y_val)], verbose=100)