示例#1
0

def rmse(y, y_hat):
    diff = np.power(y - y_hat, 2)
    return np.sqrt(np.sum(diff))

# load test data
boston = load_boston()
n = 10000

# create data matrix
data = arboretum.DMatrix(boston.data[0:n], y=boston.target[0:n])
y = boston.target[0:n]

# init model
model = arboretum.Garden('reg:linear', data, 6, 2, 1, 0.5)

# grow trees
for i in xrange(5):
    model.grow_tree()

# predict on train data set
pred = model.predict(data)

# print first n records
print pred[0:10]

#RMSE
print rmse(pred, y)

示例#2
0
        'gpu': True
    },
    'tree': {
        'eta': 0.2,
        'max_depth': 6,
        'gamma': 0.0,
        'min_child_weight': 2.0,
        'min_leaf_size': 0,
        'colsample_bytree': 1.0,
        'colsample_bylevel': 1.0,
        'lambda': 0.0,
        'alpha': 0.0
    }
})

model = arboretum.Garden(config, data)

# grow trees
for i in range(2):
    model.grow_tree()

# predict on train data set
pred = model.predict(data)

# print first n records
print(pred)

mat = xgboost.DMatrix(iris.data[index, 0:n], label=y)
param = {'max_depth': 5, 'silent': True, 'objective': "reg:logistic"}
param['nthread'] = 1
param['min_child_weight'] = 2