Пример #1
0
def build_XB(X_train,y_train,X_cal,y_cal,X_test):
    cal_prob,test_prob = 0,0
    for i in range(3):
        print("--Building and Training model %s" % i)
        seed = randrange(1,10000)
        model = XGBoostClassifier(n_iter=1000,
                                max_features=0.3,
                                max_depth=8,
                                min_child_weight=10,
                                gamma=0.0093,random_state=seed,
                                learning_rate=0.05,
                                l2_weight=0.1,
                                max_samples=0.77,
                                )
        model = CalibratedClassifierCV(base_estimator=model,method='isotonic',cv=3).fit(X_train,y_train)
        print("Model %s training complete." % i)
        test_prob += model.predict_proba(X_test)
    test_prob = test_prob/3.
    return(cal_prob,test_prob)
Пример #2
0
def build_XB1(X_train,y_train,X_cal,y_cal,X_test):
    cal_prob,test_prob = 0,0
    for i in range(5):
        print("--Building and Training model %s" % i)
        seed = randrange(1,10000)
        model = XGBoostClassifier(n_iter=500,
                                max_features=0.3,
                                max_depth=7,
                                min_child_weight=10,
                                gamma=0.0093,random_state=seed,
                                learning_rate=0.2,
                                l2_weight=0.1,
                                max_samples=0.9
                                )
        model = CalibratedClassifierCV(base_estimator=model,method='isotonic',cv=5).fit(X_train,y_train)
        print("Model %s training complete." % i)
        cal_prob += model.predict_proba(X_cal)
        test_prob += model.predict_proba(X_test)
    cal_prob = cal_prob/5.
    test_prob = test_prob/5.
    print("Average Model Loss: %0.4f" % of.logloss_mc(y_cal,cal_prob))
    return(cal_prob,test_prob)