In [1]:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier, plot_tree
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score, roc_auc_score
import matplotlib.pyplot as plt
# 1. 读取数据
print("正在读取 data.xlsx ...")
try:
df = pd.read_excel("/kaggle/input/datasets/songsammy/final-data-27123102/data.xlsx")
print(f"数据读取成功,共 {len(df)} 条记录")
except FileNotFoundError:
print("错误:未找到 data.xlsx 文件,请确保文件在当前目录下")
exit(1)
# 2. 检查必需的列是否存在
required_features = ['age', 'income', 'dti', 'delinquencies', 'loan']
label_col = 'break'
for col in required_features + [label_col]:
if col not in df.columns:
print(f"错误:数据中缺少列 '{col}',现有列:{df.columns.tolist()}")
exit(1)
# 3. 数据预处理
print("\n=== 数据预处理 ===")
# 查看缺失值
print("缺失值统计:")
print(df[required_features + [label_col]].isnull().sum())
# 处理缺失值:数值特征用中位数填充,标签列删除缺失行
df_clean = df[required_features + [label_col]].copy()
for feat in required_features:
if df_clean[feat].isnull().any():
median_val = df_clean[feat].median()
df_clean[feat].fillna(median_val, inplace=True)
print(f"特征 {feat} 缺失值已用中位数 {median_val:.2f} 填充")
if df_clean[label_col].isnull().any():
# 标签缺失直接删除
df_clean = df_clean.dropna(subset=[label_col])
print(f"标签列 {label_col} 存在缺失,已删除缺失行")
# 处理异常值
for feat in required_features:
mean = df_clean[feat].mean()
std = df_clean[feat].std()
upper = mean + 3 * std
lower = mean - 3 * std
outliers = (df_clean[feat] > upper) | (df_clean[feat] < lower)
if outliers.any():
median = df_clean[feat].median()
df_clean.loc[outliers, feat] = median
print(f"特征 {feat} 存在 {outliers.sum()} 个异常值,已替换为中位数 {median}")
# 4. 特征与标签分离
X = df_clean[required_features]
y = df_clean[label_col]
if y.dtype == 'object' or y.nunique() > 2:
print(f"标签列原始值:{y.unique()}")
y = y.apply(lambda x: 1 if str(x) in ['1', '违约', 'bad', 'default', 'yes'] else 0)
print("已将标签转换为二分类(1=违约,0=正常)")
else:
y = y.astype(int)
print(f"\n数据集形状:{X.shape}")
print(f"违约样本占比:{y.mean():.2%}")
# 5. 划分训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42, stratify=y
)
# 6. 构建CART决策树模型
cart = DecisionTreeClassifier(
criterion='gini',
max_depth=3,
min_samples_split=10,
min_samples_leaf=5,
random_state=42
)
# 训练模型
cart.fit(X_train, y_train)
# 打印树的结构信息
print(f"\n决策树深度:{cart.get_depth()}")
print(f"叶子节点数量:{cart.get_n_leaves()}")
# 7. 模型评估
y_pred = cart.predict(X_test)
y_pred_proba = cart.predict_proba(X_test)[:, 1]
acc = accuracy_score(y_test, y_pred)
print(f"\n=== 模型评估 ===")
print(f"测试集准确率:{acc:.4f}")
print("\n分类报告:")
print(classification_report(y_test, y_pred, target_names=['正常', '违约']))
print("混淆矩阵:")
print(confusion_matrix(y_test, y_pred))
# AUC
auc = roc_auc_score(y_test, y_pred_proba)
print(f"AUC:{auc:.4f}")
# 8. 特征重要性
importance = pd.DataFrame({
'特征': required_features,
'重要性': cart.feature_importances_
}).sort_values('重要性', ascending=False)
print("\n特征重要性:")
print(importance)
# 9. 可视化决策树
plt.figure(figsize=(20, 10))
plot_tree(cart,
feature_names=required_features,
class_names=['正常', '违约'],
filled=True,
rounded=True,
fontsize=12,
proportion=True)
plt.title("CART决策树用于P2P网贷用户信用评价(深度=3,三个以上分枝)", fontsize=16)
plt.tight_layout()
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
plt.show()
# 10. 预测示例
def predict_credit(age, income, dti, delinquencies, loan):
"""预测新用户的信用状况"""
new_user = pd.DataFrame([[age, income, dti, delinquencies, loan]],
columns=required_features)
prob = cart.predict_proba(new_user)[0][1]
pred = cart.predict(new_user)[0]
return "违约" if pred == 1 else "正常", prob
# 测试样例
example_age, example_income = 35, 12
example_dti, example_deline, example_loan = 0.4, 2, 5
status, prob = predict_credit(example_age, example_income, example_dti, example_deline, example_loan)
print(f"\n=== 新用户预测示例 ===")
print(f"年龄={example_age}, 收入={example_income}万, 负债比={example_dti}, 逾期次数={example_deline}, 借款={example_loan}万")
print(f"预测结果:{status},违约概率:{prob:.2f}")
正在读取 data.xlsx ...
数据读取成功,共 1000 条记录
=== 数据预处理 ===
缺失值统计:
age 0
income 0
dti 0
delinquencies 0
loan 0
break 0
dtype: int64
特征 delinquencies 存在 31 个异常值,已替换为中位数 0.0
数据集形状:(1000, 5)
违约样本占比:15.80%
决策树深度:3
叶子节点数量:8
=== 模型评估 ===
测试集准确率:0.9100
分类报告:
precision recall f1-score support
正常 0.91 0.99 0.95 168
违约 0.89 0.50 0.64 32
accuracy 0.91 200
macro avg 0.90 0.74 0.79 200
weighted avg 0.91 0.91 0.90 200
混淆矩阵:
[[166 2]
[ 16 16]]
AUC:0.8404
特征重要性:
特征 重要性
3 delinquencies 0.607265
1 income 0.268294
2 dti 0.100547
4 loan 0.023894
0 age 0.000000
/usr/local/lib/python3.12/dist-packages/sklearn/tree/_export.py:673: UserWarning: Glyph 27491 (\N{CJK UNIFIED IDEOGRAPH-6B63}) missing from font(s) DejaVu Sans.
ann.update_bbox_position_size(renderer)
/usr/local/lib/python3.12/dist-packages/sklearn/tree/_export.py:673: UserWarning: Glyph 24120 (\N{CJK UNIFIED IDEOGRAPH-5E38}) missing from font(s) DejaVu Sans.
ann.update_bbox_position_size(renderer)
/usr/local/lib/python3.12/dist-packages/sklearn/tree/_export.py:673: UserWarning: Glyph 36829 (\N{CJK UNIFIED IDEOGRAPH-8FDD}) missing from font(s) DejaVu Sans.
ann.update_bbox_position_size(renderer)
/usr/local/lib/python3.12/dist-packages/sklearn/tree/_export.py:673: UserWarning: Glyph 32422 (\N{CJK UNIFIED IDEOGRAPH-7EA6}) missing from font(s) DejaVu Sans.
ann.update_bbox_position_size(renderer)
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 20915 (\N{CJK UNIFIED IDEOGRAPH-51B3}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 31574 (\N{CJK UNIFIED IDEOGRAPH-7B56}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 26641 (\N{CJK UNIFIED IDEOGRAPH-6811}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 29992 (\N{CJK UNIFIED IDEOGRAPH-7528}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 20110 (\N{CJK UNIFIED IDEOGRAPH-4E8E}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 32593 (\N{CJK UNIFIED IDEOGRAPH-7F51}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 36151 (\N{CJK UNIFIED IDEOGRAPH-8D37}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 25143 (\N{CJK UNIFIED IDEOGRAPH-6237}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 20449 (\N{CJK UNIFIED IDEOGRAPH-4FE1}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 35780 (\N{CJK UNIFIED IDEOGRAPH-8BC4}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 20215 (\N{CJK UNIFIED IDEOGRAPH-4EF7}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 65288 (\N{FULLWIDTH LEFT PARENTHESIS}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 28145 (\N{CJK UNIFIED IDEOGRAPH-6DF1}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 24230 (\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 65292 (\N{FULLWIDTH COMMA}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 19977 (\N{CJK UNIFIED IDEOGRAPH-4E09}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 20010 (\N{CJK UNIFIED IDEOGRAPH-4E2A}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 20197 (\N{CJK UNIFIED IDEOGRAPH-4EE5}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 19978 (\N{CJK UNIFIED IDEOGRAPH-4E0A}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 26525 (\N{CJK UNIFIED IDEOGRAPH-679D}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:124: UserWarning: Glyph 65289 (\N{FULLWIDTH RIGHT PARENTHESIS}) missing from font(s) DejaVu Sans.
plt.tight_layout()
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 20915 (\N{CJK UNIFIED IDEOGRAPH-51B3}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 31574 (\N{CJK UNIFIED IDEOGRAPH-7B56}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 26641 (\N{CJK UNIFIED IDEOGRAPH-6811}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 29992 (\N{CJK UNIFIED IDEOGRAPH-7528}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 20110 (\N{CJK UNIFIED IDEOGRAPH-4E8E}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 32593 (\N{CJK UNIFIED IDEOGRAPH-7F51}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 36151 (\N{CJK UNIFIED IDEOGRAPH-8D37}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 25143 (\N{CJK UNIFIED IDEOGRAPH-6237}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 20449 (\N{CJK UNIFIED IDEOGRAPH-4FE1}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 35780 (\N{CJK UNIFIED IDEOGRAPH-8BC4}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 20215 (\N{CJK UNIFIED IDEOGRAPH-4EF7}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 65288 (\N{FULLWIDTH LEFT PARENTHESIS}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 28145 (\N{CJK UNIFIED IDEOGRAPH-6DF1}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 24230 (\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 65292 (\N{FULLWIDTH COMMA}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 19977 (\N{CJK UNIFIED IDEOGRAPH-4E09}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 20010 (\N{CJK UNIFIED IDEOGRAPH-4E2A}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 20197 (\N{CJK UNIFIED IDEOGRAPH-4EE5}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 19978 (\N{CJK UNIFIED IDEOGRAPH-4E0A}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 26525 (\N{CJK UNIFIED IDEOGRAPH-679D}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 65289 (\N{FULLWIDTH RIGHT PARENTHESIS}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 27491 (\N{CJK UNIFIED IDEOGRAPH-6B63}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 24120 (\N{CJK UNIFIED IDEOGRAPH-5E38}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 36829 (\N{CJK UNIFIED IDEOGRAPH-8FDD}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/tmp/ipykernel_16/2469662666.py:125: UserWarning: Glyph 32422 (\N{CJK UNIFIED IDEOGRAPH-7EA6}) missing from font(s) DejaVu Sans.
plt.savefig('cart_decision_tree.png', dpi=300, bbox_inches='tight')
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 20915 (\N{CJK UNIFIED IDEOGRAPH-51B3}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 31574 (\N{CJK UNIFIED IDEOGRAPH-7B56}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 26641 (\N{CJK UNIFIED IDEOGRAPH-6811}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 29992 (\N{CJK UNIFIED IDEOGRAPH-7528}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 20110 (\N{CJK UNIFIED IDEOGRAPH-4E8E}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 32593 (\N{CJK UNIFIED IDEOGRAPH-7F51}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 36151 (\N{CJK UNIFIED IDEOGRAPH-8D37}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 25143 (\N{CJK UNIFIED IDEOGRAPH-6237}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 20449 (\N{CJK UNIFIED IDEOGRAPH-4FE1}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 35780 (\N{CJK UNIFIED IDEOGRAPH-8BC4}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 20215 (\N{CJK UNIFIED IDEOGRAPH-4EF7}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 65288 (\N{FULLWIDTH LEFT PARENTHESIS}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 28145 (\N{CJK UNIFIED IDEOGRAPH-6DF1}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 24230 (\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 65292 (\N{FULLWIDTH COMMA}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 19977 (\N{CJK UNIFIED IDEOGRAPH-4E09}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 20010 (\N{CJK UNIFIED IDEOGRAPH-4E2A}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 20197 (\N{CJK UNIFIED IDEOGRAPH-4EE5}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 19978 (\N{CJK UNIFIED IDEOGRAPH-4E0A}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 26525 (\N{CJK UNIFIED IDEOGRAPH-679D}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 65289 (\N{FULLWIDTH RIGHT PARENTHESIS}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 27491 (\N{CJK UNIFIED IDEOGRAPH-6B63}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 24120 (\N{CJK UNIFIED IDEOGRAPH-5E38}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 36829 (\N{CJK UNIFIED IDEOGRAPH-8FDD}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
/usr/local/lib/python3.12/dist-packages/IPython/core/pylabtools.py:151: UserWarning: Glyph 32422 (\N{CJK UNIFIED IDEOGRAPH-7EA6}) missing from font(s) DejaVu Sans.
fig.canvas.print_figure(bytes_io, **kw)
=== 新用户预测示例 === 年龄=35, 收入=12万, 负债比=0.4, 逾期次数=2, 借款=5万 预测结果:违约,违约概率:0.94