XGBoost में Regularization और बेस लर्नर्स

XGBoost के साथ Extreme Gradient Boosting

Sergey Fogelson

Head of Data Science, TelevisaUnivision

XGBoost में Regularization

  • Regularization मॉडल की जटिलता पर नियंत्रण है
  • ऐसे मॉडल चाहिए जो सटीक हों और जितने सरल हों उतना अच्छा
  • XGBoost में Regularization पैरामीटर:
    • gamma - किसी split के होने के लिए न्यूनतम loss reduction
    • alpha - पत्तियों के weights पर l1 regularization, बड़ा मान मतलब ज़्यादा regularization
    • lambda - पत्तियों के weights पर l2 regularization
XGBoost के साथ Extreme Gradient Boosting

XGBoost में L1 regularization का उदाहरण

import xgboost as xgb
import pandas as pd
boston_data = pd.read_csv("boston_data.csv")
X,y = boston_data.iloc[:,:-1],boston_data.iloc[:,-1]

boston_dmatrix = xgb.DMatrix(data=X,label=y) params={"objective":"reg:squarederror","max_depth":4}
l1_params = [1,10,100] rmses_l1=[]
for reg in l1_params: params["alpha"] = reg cv_results = xgb.cv(dtrain=boston_dmatrix, params=params,nfold=4, num_boost_round=10,metrics="rmse",as_pandas=True,seed=123) rmses_l1.append(cv_results["test-rmse-mean"].tail(1).values[0])
print("Best rmse as a function of l1:") print(pd.DataFrame(list(zip(l1_params,rmses_l1)), columns=["l1","rmse"]))
Best rmse as a function of l1:
        l1          rmse
    0    1  69572.517742
    1   10  73721.967141
    2  100  82312.312413
XGBoost के साथ Extreme Gradient Boosting

XGBoost में Base learners

  • Linear Base Learner:
    • linear terms का योग
    • boosted मॉडल linear मॉडलों का weighted sum है (खुद linear)
    • कम इस्तेमाल होता है
  • Tree Base Learner:
    • decision tree
    • boosted मॉडल decision trees का weighted sum है (nonlinear)
    • XGBoost में लगभग हमेशा यही प्रयोग होता है
XGBoost के साथ Extreme Gradient Boosting

बराबर-लंबाई की कई lists से DataFrame बनाना

  • pd.DataFrame(list(zip(list1,list2)),columns=["list1","list2"]))
  • zip समानांतर मानों का generator बनाता है:
    • zip([1,2,3],["a","b""c"]) = [1,"a"],[2,"b"],[3,"c"]
    • generators को DataFrame में उपयोग से पहले पूरी तरह instantiate करना पड़ता है
  • list() पूरा generator instantiate करता है और उसे DataFrame में पास करने से पूरी अभिव्यक्ति convert हो जाती है
XGBoost के साथ Extreme Gradient Boosting

अभ्यास करते हैं!

XGBoost के साथ Extreme Gradient Boosting

Preparing Video For Download...