Esempio n. 1
0
def test():
    x = [[0.5, 0.6, 0.7], [0.4, 0.5, 0.5], [1.2, 1.3, 1.0], [1.4, 1.5, 0.8],
         [1.5, 1.3, 1.3]]
    y = [0, 0, 1, 1, 1]
    c = Config()
    gbdt = GBDT(config=c)
    gbdt.buildGbdt(x, y)
    data_features = gbdt.generateFeatures(x)
    print len(data_features[0])
Esempio n. 2
0
def main():
    X_train, X_train_lr, y_train, y_train_lr,X_test, y_test=generate_data()
    config=Config()
    gbdt=GBDT(config=config)
    gbdt.buildGbdt(X_train,y_train)
    trainDataFeatures=gbdt.generateFeatures(X_train_lr)
    testDataFeatures=gbdt.generateFeatures(X_test)
    print len(trainDataFeatures[0])
    lrModel = LogisticRegression()
    lrModel.fit(trainDataFeatures,y_train_lr)
    #test model
    testLabel = lrModel.predict(testDataFeatures)
    accuracy = np.sum((np.array(testLabel)==np.array(y_test)))*1.0/len(y_test)
    print ("the accuracy is % f"%accuracy)