我正在尝试使用teradataml生成XGBoost模型。此示例将说明如何在teradataml中使用xgboost。 假设培训和测试数据存在于teradata数据库中。
答案 0 :(得分:1)
导入库
import teradataml
from teradataml.context.context import *
from teradataml.dataframe.dataframe import DataFrame
from teradataml.analytics.mle.XGBoost import XGBoost
from teradataml.analytics.mle.XGBoostPredict import XGBoostPredict
创建上下文
housing_train_binary = DataFrame.from_table("housing_train_binary")
housing_test_binary = DataFrame.from_table("housing_test_binary")
生成模型
xgboostmodel = XGBoost(data=housing_train_binary,
id_column='sn',
formula=" homestyle ~ driveway + recroom + fullbase + gashw + airco + prefarea ",
num_boosted_trees=2,
loss_function='SOFTMAX',
prediction_type='CLASSIFICATION',
reg_lambda=1.0,
shrinkage_factor=0.1,
column_subsampling=1.0,
iter_num=10,
min_node_size=1,
max_depth=12,
variance=0.0,
seed=1,
data_sequence_column=['sn', 'homestyle']
);
预测
xgpredict = XGBoostPredict(newdata=housing_test_binary, object=result, object_order_column=['tree_id', 'iter','class_num']);