添加完整的客户流失预测系统,包括数据处理、模型训练、预测和行动建议功能。主要包含以下模块: 1. 数据预处理流水线(Polars + Pandera) 2. 机器学习模型训练(LightGBM + Logistic Regression) 3. AI Agent预测和建议工具 4. Streamlit交互式Web界面 5. 完整的课程设计报告文档
27 lines
723 B
Python
27 lines
723 B
Python
import requests
|
||
import zipfile
|
||
import os
|
||
|
||
# 下载Telco Customer Churn数据集
|
||
def download_telco_churn():
|
||
# 使用公开可访问的数据集URL
|
||
url = "https://raw.githubusercontent.com/IBM/telco-customer-churn-on-icp4d/master/data/Telco-Customer-Churn.csv"
|
||
|
||
# 创建data目录(如果不存在)
|
||
os.makedirs("data", exist_ok=True)
|
||
|
||
# 下载文件
|
||
response = requests.get(url)
|
||
response.raise_for_status()
|
||
|
||
# 保存文件
|
||
file_path = "data/Telco-Customer-Churn.csv"
|
||
with open(file_path, "wb") as f:
|
||
f.write(response.content)
|
||
|
||
print(f"数据集已成功下载到 {file_path}")
|
||
return file_path
|
||
|
||
if __name__ == "__main__":
|
||
download_telco_churn()
|