python - teradataml:如何使用 teradataml 生成 xgboost 模型?
问题描述
我正在尝试使用 teradataml 生成 XGBoost 模型。此示例将展示如何在 teradataml 中使用 xgboost。假设训练和测试数据存在于 teradata 数据库中。
解决方案
导入库
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']);
推荐阅读
- mongodb - 在 mongodb 上按年分组
- jmeter - 在mac上运行jmeter的问题
- sql - 在同一列的行之间应用条件
- azure-ad-b2c - 用户旅程正文中的 Azure B2C Rest API 为空
- php - PHP,数组-混合顺序,steam api返回不同顺序
- sas - SAS:如何测试一个值在时间之间的稳定性
- javascript - SameSite=Lax 是否应该允许 3rd-party GET?
- python - 如何将外部库导入 Ansible 模块?
- asp.net - .NET ApiController:使用 [FromBody] T 的自定义模型绑定行为
- python - 无法使用 scrapy 提取完整的 url @href