客户流失预测:识别有流失风险的客户并干预
FreeGuideOnline
最新
2026-06-23
python from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import classification_report
X 为经过特征工程后的 DataFrame,y 为流失标签
X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, test_size=0.3)
model = RandomForestClassifier(n_estimators=100, max_depth=10, class_weight='balanced') model.fit(X_train, y_train)
y_pred = model.predict(X_test) print(classification_report(y_test, y_pred))