1. 环境准备
CREATE TABLE customers ( customer_id NUMBER, age NUMBER, tenure NUMBER, spend NUMBER, churn_flag NUMBER );
INSERT INTO customers ...; -- 插入带标签的数据
使用AutoML训练模型:
DECLARE
model BINARY_DOUBLE;
BEGIN
DBMS_AUTO_TASK.CREATE_TASK(
task_name => 'churn_prediction',
task_type => DBMS_AUTO_TASK.TASK_TYPE_AUTOML,
table_name => 'customers',
target_column => 'churn_flag',
settings => '{"ENABLE_INTERPRETABILITY": true}');
model := DBMS_AUTO_TASK.EXECUTE_TASK('churn_prediction');
END;
部署模型进行预测:
SELECT customer_id, PREDICT(churn_prediction, age, tenure, spend) AS churn_prob FROM customers;
DBMS_AUTO_TASK.GET_METRICS查看模型评估指标(AUC、准确率等)。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31547506/viewspace-3114941/ ,如需转载,请注明出处,否则将追究法律责任。