当前位置:首页>python>期刊图片复现|Python绘制SHAP重要性玫瑰图+相关性网络图组合图

期刊图片复现|Python绘制SHAP重要性玫瑰图+相关性网络图组合图

  • 2026-02-07 16:12:09
期刊图片复现|Python绘制SHAP重要性玫瑰图+相关性网络图组合图

代码绘制成果展示

论文:Interpretable multimodal  radiopathomics model predicting  pathological complete response to  neoadjuvant chemoimmunotherapy in esophageal squamous cell carcinoma
论文原图
该图是一个集成了SHAP可解释性分析与特征互涉关系的综合图,分为左侧的SHAP分析(a)和右侧的特征相关性网络图(B)两大部分。
图(a)中,依据平均绝对SHAP值对特征进行了降序排列,条形的长度代表特征的全局重要性,即该特征对模型预测结果的平均贡献幅度,条形越长且颜色越红说明该特征越关键;左下角的嵌入式玫瑰图则以百分比形式补充展示了各特征的相对贡献占比。SHAP蜂巢图用于展示特征的具体影响方向和分布:每一行对应左侧的一个特征,行中的每一个点代表一个样本;右侧最边缘的色条指示了特征本身的数值大小,红色代表该特征取值高,蓝色代表取值低;X轴代表特征对模型输出的影响值,点位于0轴右侧表示该样本的特征值导致预测结果增加,位于左侧则表示导致结果减少。
图(B)展示了特征相关性网络,圆圈节点代表具体的特征变量,节点的颜色区分了不同类别的特征,节点之间的连线表示特征间的相关性,橙色实线代表正相关,蓝色虚线代表负相关,线条的越粗表示相关性越强,这有助于理解特征之间是否存在共线性或协同变化关系。
仿图
多种配色

代码解释

第一部分

库的导入以及字体设置
# =========================================================================================# ====================================== 1. 环境设置 =======================================# =========================================================================================import pandas as pdimport numpy as npimport xgboostimport shapimport matplotlib.pyplot as pltimport matplotlib.colors as mcolorsimport matplotlib.ticker as tickerfrom matplotlib.cm import ScalarMappablefrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import StandardScalerfrom shap.plots import beeswarmfrom sklearn.model_selection import GridSearchCV

第二部分

SHAP图颜色库的设置以及配色方案的选择
# =========================================================================================# ======================================2.shap图颜色库=======================================# =========================================================================================COLOR_SCHEMES = {    1: ["blue""#4B0082""red"],}# 设置当前使用的颜色方案SCHEME_ID = 29

第三部分

网络图颜色库的设置以及配色方案的选择
# =========================================================================================# ====================================== 3.网络图部分颜色库 ===========================# =========================================================================================NETWORK_COLOR_SCHEMES = {    1: {        'node_path''#D689C5',        'node_rad''#92C2DD',        'edge_pos''#8E44AD',        'edge_neg''#3498DB'    },}# 设置当前网络图配色SCHEME_ID2  = 29

第四部分

特征重要性条形图和径向图/玫瑰图组合图绘制函数的开始部分。创建画布,手动计算布局参数来精确控制子图位置,添加两个坐标轴:一个用于左侧的颜色条,一个用于主要的条形图。绘制颜色条,去掉了默认刻度,并手动在颜色条的上下添加了“High”和“Low”文本,以及侧面的标题,用于指示SHAP值的大小方向。
# =========================================================================================# ======================================4.特征重要性条形图和径向图/玫瑰图绘制函数=======================================# =========================================================================================def draw_bar_and_radial(sorted_features, sorted_shap_values, bar_colors, cmap, color_norm):    fig = plt.figure(figsize=(1615))  # 创建画布    # 画布边距    left_margin, right_margin, bottom_margin, top_margin = 0.080.080.120.12    # 颜色条宽度    colorbar_width = 0.02    # 计算绘图区域的底部位置和高度    plot_bottom = bottom_margin    plot_height = 1.0 - bottom_margin - top_margin    # 颜色条的左侧位置    cbar_left = left_margin    # 条形图的左侧位置    main_ax_left = cbar_left + colorbar_width + 0.04    # 条形图的宽度    main_ax_width = 1.0 - main_ax_left - right_margin    # 添加颜色条的坐标轴    ax_cbar = fig.add_axes([cbar_left, plot_bottom, colorbar_width, plot_height])    ax_cbar.text(0.5,                 -0.01,                 'Low'                 '', transform=ax_cbar.transAxes,                 ha='center',                 va='top',                 fontsize=24)    # 去掉颜色条边框    cbar.outline.set_visible(False)    # 颜色条标题    ax_cbar.text(-1.4,                 0.5,                 'Contribution for CEs ($10^4$ t)',                 transform=ax_cbar.transAxes,                 fontsize=24,                 rotation=90,                 va='center')

第五部分

特征重要性条形图和径向图/玫瑰图组合图绘制函数的条形图部分,这一部分负责绘制特征重要性的水平条形图,根据SHAP值大小反转了Y轴,使得最重要的特征显示在顶部,反转了X轴,隐藏了Y轴的默认刻度标签,使用 text 函数手动在条形图的右侧添加特征名称。
ax_bar.xaxis.tick_bottom()  # 条形图x轴刻度位置    ax_bar.xaxis.set_label_position("bottom")  # 设置x轴标签位置    # 反转x轴方向    ax_bar.invert_xaxis()    # 绘制水平条形图    ax_bar.barh(y=range(len(sorted_features)),  # Y坐标                width=sorted_shap_values,  # 水平条形宽度                color=bar_colors,  # 条形颜色                height=0.6)  # 条形高度    # 反转y轴方向,使最重要的特征排在顶部    ax_bar.invert_yaxis()    # 设置x轴标签    ax_bar.set_xlabel('Contribution for CEs ($10^4$ t)', size=24, labelpad=20)    # 移除y轴刻度    ax_bar.set_yticks([])    # 去掉左侧和顶部边框    ax_bar.spines[['left''top']].set_visible(False)    # 设置右侧边框位置    ax_bar.spines['right'].set_position(('data'0))    # 显示边框    ax_bar.spines['right'].set_visible(True)    ax_bar.spines['bottom'].set_visible(True)                       direction='in',                       length=4)    # 标签的x轴偏移量    label_x_padding = 0.005    # 遍历特征,在条形图旁边添加特征名称文本    for i, feature in enumerate(sorted_features):        ax_bar.text(label_x_padding,                    i,                    feature,                    ha='right',                    va='center',                    color='black',                    fontsize=24)    # 子图标签    ax_bar.text(0.02,                0.98,                '(a)',                transform=ax_bar.transAxes,                fontsize=30,                weight='bold',                ha='left',                va='top')

第六部分

特征重要性条形图和径向图/玫瑰图组合图绘制函数的径向图/玫瑰图部分,这一部分在图表的左下角创建了一个嵌入的径向图/玫瑰图。使用创建极坐标系。计算了每个特征重要性占比,以此决定扇形的角度宽度。扇形由两部分组成:内部的灰白交替背景和外部根据SHAP值着色的环。计算了角度和半径位置,精确放置每个扇形和百分比标签。最后,隐藏了极坐标系的轴线和网格,调整了方向,并将生成的图片保存到指定路径。
inset_left = main_ax_left - 0.15  # 径向图/玫瑰图的左侧位置    inset_bottom = plot_bottom - 0.05  # 径向图/玫瑰图的底部位置    inset_size = min(main_ax_width, plot_height) * 0.85  # 径向图/玫瑰图的大小    # 定义径向图/玫瑰图的矩形区域    inset_ax_rect = [inset_left, inset_bottom, inset_size, inset_size]    # 添加坐标轴作为径向图/玫瑰图    ax_radial_inset = fig.add_axes(inset_ax_rect, projection='polar')    # 背景透明    ax_radial_inset.patch.set_alpha(0)ng_width = 3.00.52.0    # 计算每个扇形的总长度/半径    total_lengths = [base_length + i * fixed_increment for i in range(num_vars)]    # 计算内部灰色部分的长度    inner_heights = [max(0, tl - colored_ring_width) for tl in total_lengths]    # 定义内部颜色列表    inner_colors = ['#EAEAEA''#FFFFFF'] * (num_vars // 2 + 1)    # 截取对应数量的颜色    inner_colors = inner_colors[:num_vars]    # 起始角度偏移量    one_oclock_offset = np.pi / 21    # 每个扇形的起始角度    thetas = np.cumsum([0] + widths[:-1].tolist()) - one_oclock_offset    # 绘制内部灰色扇形    ax_radial_inset.bar(x=thetas,  # 条形的起始角度位置                        height=inner_heights,  # 内部灰色部分的长度                        width=widths,  # 指定每个条形的角宽度                        color=inner_colors,  # 条形的填充颜色                        align='edge',  # 对齐方式为边缘对齐                        edgecolor='white',  # 条形边框的颜色为白色                        linewidth=1.5)  # 条形边框线的宽度                             va='center',                             fontsize=18)    ax_radial_inset.set_yticklabels([])  # 移除径向图的y轴标签    ax_radial_inset.set_xticklabels([])  # 移除径向图的x轴标签    # 隐藏极坐标轴的脊柱    ax_radial_inset.spines['polar'].set_visible(False)    # 关闭网格    ax_radial_inset.grid(False)    ax_radial_inset.set_theta_zero_location('N')  # 正北方向    ax_radial_inset.set_theta_direction(-1)  # 顺时针    ax_radial_inset.set_ylim(0max(total_lengths) + 2)  # 半径范围

第七部分

SHAP蜂巢图绘制函数,使用 shap.summary_plot 绘制标准的SHAP蜂巢图。
# =========================================================================================# ======================================5.SHAP蜂巢图函数=======================================# =========================================================================================def draw_native_beeswarm(shap_values, X, cmap):    plt.figure(figsize=(1615))  # 创建画布    # 绘制蜂巢图    shap.summary_plot(shap_values,  # SHAP值数据                      X,  # 对应的特征矩阵数据                      plot_type="dot",  # 蜂巢图                      show=False,  # 不立即显示                      cmap=cmap)  # 颜色映射    # 获取当前坐标轴    ax = plt.gca()    # 设置x轴标签    ax.set_xlabel("SHAP Value (impact on model output)", fontsize=18)    # y轴刻度标签    ax.tick_params(axis='y', labelsize=16)    # x轴刻度标签    ax.tick_params(axis='x', labelsize=14)    # 如果存在多个坐标轴    if len(plt.gcf().axes) > 1:        cbar_ax = plt.gcf().axes[-1]  # 获取颜色条坐标轴        cbar_ax.set_ylabel('Feature Value', size=16, rotation=-90, labelpad=20)  # 设置颜色条标签        cbar_ax.tick_params(labelsize=14)  # 设置颜色条刻度标签大小    # 调整布局    plt.tight_layout()

第八部分

无Y轴标签的SHAP蜂巢图绘制函数,这个函数的功能与上一个类似,但有一个区别,显移除了Y轴的标签。用于组合图的右侧部分,因为左侧的图表已经包含了特征名称。
# =========================================================================================# ======================================6.无Y轴标签的SHAP蜂巢图的函数=======================================# =========================================================================================def draw_beeswarm_no_labels(shap_values, X, cmap):    # 创建画布    plt.figure(figsize=(1615))    # 绘制蜂巢图    shap.summary_plot(shap_values,                      X,                      plot_type="dot",                      show=False,                      cmap=cmap)    # 获取当前坐标轴    ax_third_plot = plt.gca()    # 移除y轴刻度标签(特征名)    ax_third_plot.set_yticklabels([])    # x轴标题    ax_third_plot.set_xlabel("SHAP Value (impact on model output)", fontsize=18)    # x轴刻度标签    ax_third_plot.tick_params(axis='x', labelsize=14)    # 处理颜色条(如果存在)    if len(plt.gcf().axes) > 1:        cbar_ax_third = plt.gcf().axes[-1]  # 获取当前图形对象列表中的最后一个坐标轴        cbar_ax_third.set_ylabel('Feature Value',  # Y轴名                                 size=16,  # 字体大小                                 rotation=-90,  # 旋转                                 labelpad=20)  # 文本与坐标轴之间的距离        cbar_ax_third.tick_params(labelsize=14)  # 字体大小    # 调整布局    plt.tight_layout()

第九部分

组合图绘制函数左侧,创建了一个大画布,设置了左右两个主绘图区域。按6:4的比例分配左侧(条形图+玫瑰图)和右侧(蜂巢图)的空间。
# =========================================================================================# ======================================7.特征重要性条形图+蜂巢图+玫瑰图组合图绘制函数=======================================# =========================================================================================def draw_combined_plot(sorted_features, sorted_shap_values, shap_values, bar_colors, cmap, color_norm):    # 创建画布    fig_combined = plt.figure(figsize=(3425))    # 定义边距和间距参数    left_margin, right_margin, bottom_margin, top_margin = 0.050.050.020.1    space_between = 0.01  # 左右子图之间的间距    plot_bottom = bottom_margin  # 绘图区域的底部    plot_height = 1 - bottom_margin - top_margin  # 绘图区域的高度    total_plot_width = 1 - left_margin - right_margin - space_between  # 宽度    # 分配左侧图和右侧图的宽度比例    left_plot_width = total_plot_width * 0.6    right_plot_width = total_plot_width * 0.4    cbar_left = 0.1  # 颜色条位置    colorbar_width = 0.01  # 颜色条宽度    # 颜色条坐标轴    ax_cbar_new = fig_combined.add_axes([cbar_left, plot_bottom, colorbar_width, plot_height])    # 创建ScalarMappable对象,用于颜色映射    sm = ScalarMappable(cmap=cmap, norm=color_norm)    # 绘制颜色条    cbar = fig_combined.colorbar(sm,                                 cax=ax_cbar_new,                                 orientation='vertical')    # 设置标签    cbar.set_label('', size=18, labelpad=5)    # 移除刻度    cbar.set_ticks([])    # 设置刻度位置    cbar.ax.yaxis.set_ticks_position('left')    # 上文本    ax_cbar_new.text(0.5,                     1.01,  # y坐标位置                     'High',  # 文本内容                     transform=ax_cbar_new.transAxes,  # 使用相对坐标                     ha='center',  # 水平居中                     va='bottom',  # 垂直底部对齐                     fontsize=30)  # 字体大小    # 左侧条形图的位置    main_ax_left = cbar_left + colorbar_width + 0.05    # 添加条形图坐标轴    ax_bar_new = fig_combined.add_axes([main_ax_left,  # 左                                        plot_bottom,  # 下                                        left_plot_width,  # 宽度                                        plot_height])  # 高度    # x轴刻度在底部    ax_bar_new.xaxis.tick_bottom()    # 设置x轴标签    ax_bar_new.xaxis.set_label_position("bottom")    # 反转x轴    ax_bar_new.invert_xaxis()    # 绘制水平条形    ax_bar_new.barh(y=range(len(sorted_features)),  # 数据                    width=sorted_shap_values,  # 条形宽度                    color=bar_colors,  # 颜色                    height=0.6)  # 条形高度    # 反转y轴    ax_bar_new.invert_yaxis()    # 设置x轴标题    ax_bar_new.set_xlabel('Contribution for CEs ($10^4$ t)', size=30, labelpad=20)    # 移除y轴刻度    ax_bar_new.set_yticks([])    # 去掉边框    ax_bar_new.spines[['left''top']].set_visible(False)    # 设置右侧边框位置    ax_bar_new.spines['right'].set_position(('data'0))    # 显示边框    ax_bar_new.spines['right'].set_visible(True)    ax_bar.spines['bottom'].set_visible(True)    # 主刻度样式    ax_bar_new.tick_params(axis='x',  # 轴                           which='major',  # 主刻度                           direction='in',  # 朝内                           labelsize=30,  # 标签大小                           length=6,  # 刻度长度                           pad=8)  # 刻度间距    # 图标签    ax_bar_new.text(-0.02,  # x坐标                    0.98,  # y坐标                    '(a)',  # 文本内容                    transform=ax_bar_new.transAxes,  # 使用相对坐标                    fontsize=80,  # 字体大小                    weight='bold',  # 字体加粗                    ha='left',  # 水平左对齐                    va='top')  # 垂直顶部对齐

第十部分

组合图绘制函数的中部嵌入径向图,在组合图的左侧区域下方嵌入了径向图/玫瑰图。
    num_vars = len(sorted_features)  # 特征数量    # 百分比    percentages = (sorted_shap_values / sorted_shap_values.sum()) * 100    # 每个扇形的宽度    widths = (sorted_shap_values / sorted_shap_values.sum()) * 2 * np.pi    # 设置基础长度、增量和彩色环宽度    base_length, fixed_increment, colored_ring_width = 3.00.52.0    # 每个扇形的总长度    total_lengths = [base_length + i * fixed_increment for i in range(num_vars)]    # 累积角度    thetas = np.cumsum([0] + widths[:-1].tolist()) - one_oclock_offset    inset_size = min(left_plot_width, plot_height) * 1.3  # 计算大小    # 左边距    inset_left = main_ax_left - 0.2    # 底边距    inset_bottom = plot_bottom - 0.1    # 定义插图矩形区域    inset_ax_rect = [inset_left, inset_bottom, inset_size, inset_size]    # 添加径向极坐标轴    ax_radial_inset_new = fig_combined.add_axes(inset_ax_rect, projection='polar')    # 背景透明    ax_radial_inset_new.patch.set_alpha(0)    # 绘制内部背景条    ax_radial_inset_new.bar(x=thetas,  # 角度                            height=inner_heights,  # 高度                            width=widths,  # 宽度                            color=inner_colors,  # 颜色                            align='edge',  # 对齐方式                            edgecolor='white',  # 边缘颜色                            linewidth=1.5)  # 线宽    # 绘制外部彩色条    ax_radial_inset_new.bar(x=thetas,  # 角度                            height=[colored_ring_width] * num_vars,  # 高度                            width=widths,  # 宽度                            bottom=inner_heights,  # 底部起始位置                            color=bar_colors,  # 颜色                            align='edge',  # 对齐方式                            edgecolor='white',  # 边缘颜色                            linewidth=1.5)  # 线宽    # 移除y轴标签    ax_radial_inset_new.set_yticklabels([])    # 移除x轴标签    ax_radial_inset_new.set_xticklabels([])    # 隐藏极坐标脊柱    ax_radial_inset_new.spines['polar'].set_visible(False)    # 隐藏网格    ax_radial_inset_new.grid(False)    ax_radial_inset_new.set_theta_zero_location('N')  # 正北    ax_radial_inset_new.set_theta_direction(-1)  # 顺时针    ax_radial_inset_new.set_ylim(0max(total_lengths) + 2)  # 半径范围

第十一部分

组合图绘制函数的右侧蜂巢图与保存,调用 shap.plots.beeswarm,将图形绘制在指定的坐标轴上。手动增大了散点的大小。移除了Y轴标签,并添加了X轴标签。添加子图编号,并调整了蜂巢图自带的颜色条的标签和旋转角度。将这张包组合图保存到指定文件夹。
   # 右侧蜂巢图位置    right_plot_left = main_ax_left + left_plot_width + space_between    # 添加蜂巢图坐标轴    ax_beeswarm = fig_combined.add_axes([right_plot_left, plot_bottom, right_plot_width, plot_height])    # 绘制蜂巢图    beeswarm(shap_values,  # 数据             max_display=len(sorted_features),  # 最大显示特征数             ax=ax_beeswarm,  # 指定坐标轴             show=False,  # 不立即显示             color=cmap,  # 颜色映射             plot_size=None)  # 不自动调整大小    # 遍历坐标轴上的所有散点    for collection in ax_beeswarm.collections:    # 蜂巢图颜色条    if len(fig_combined.axes) > 3:        # 获取颜色条坐标轴        cbar_ax_right = fig_combined.axes[-1]        # 设置右侧颜色条标签        cbar_ax_right.set_ylabel('Feature Value',  # 内容                                 size=30,  # 字体大小                                 rotation=270,  # 旋转                                 labelpad=5)  # 标签间距        # 刻度标签大小        cbar_ax_right.tick_params(labelsize=30)

第十二部分

网络相关性图绘制函数,计算特征间的相关系数矩阵。将所有特征节点均匀分布在一个圆周上。遍历每一对节点,如果相关系数绝对值大于0,则绘制连线。连线颜色代表正负相关,宽度和透明度代表相关性强弱。根据特征名称将特征分类,分别赋予不同的颜色。添加自定义的图例和标签,保存图片。
# =========================================================================================# ====================================== 8.网络相关性图绘制函数 ===========================# =========================================================================================def draw_right_part_network(data_df, sorted_features, corr_method='spearman'):    # 创建画布和坐标轴    fig, ax = plt.subplots(figsize=(1515))    # 获取配色方案    net_colors = NETWORK_COLOR_SCHEMES[SCHEME_ID2]    # 筛选出特征数据    selected_data = data_df[sorted_features]    # 计算筛选数据的相关性    corr_matrix = selected_data.corr(method=corr_method)    # 获取矩阵上三角部分的索引(k=1表示不包含对角线本身)    upper_tri_indices = np.triu_indices_from(corr_matrix, k=1)    # 根据索引提取所有上三角的相关系数值    all_corrs = corr_matrix.values[upper_tri_indices]    # 计算这些相关系数的绝对值    all_abs_corrs = np.abs(all_corrs)    # 最大值    max_abs = np.max(all_abs_corrs)    # 最小值    min_abs = np.min(all_abs_corrs)    # 如果最大值等于最小值    if max_abs == min_abs:        max_abs += 1e-9# 给最大值加上一个微小的数值    print(f"相关性绝对值范围: Min={min_abs:.4f}, Max={max_abs:.4f}")    # 设置连线宽度的最小值和最大值    LW_MIN, LW_MAX = 0.57    # 设置绘制连线的相关性阈值    threshold = 0.0    # 获取特征变量的数量    num_vars = len(sorted_features)    x_coords = radius * np.cos(angles)    # 计算节点的Y坐标    y_coords = radius * np.sin(angles)    # 初始化节点颜色列表    node_colors = []    # 遍历每一个特征,设置分组特征    for feat in sorted_features:        if str(feat).startswith('P'or 'Texture' in str(feat):            node_colors.append(net_colors['node_path'])        else:            node_colors.append(net_colors['node_rad'])orr > 0 else net_colors['edge_neg']                # 如果相关系数大于0使用实线,否则使用虚线                style = '-' if corr > 0 else '--'                # 对相关系数绝对值进行归一化处理                norm_score = (abs_corr - min_abs) / (max_abs - min_abs)                # 根据归一化分数计算线宽                width = LW_MIN + norm_score * (LW_MAX - LW_MIN)                # 根据归一化分数计算透明度                alpha = 0.2 + norm_score * 0.7                # 绘制连接两个节点的线条                ax.plot([x_coords[i],  # 起始节点和终止节点的X坐标                         x_coords[j]],                        [y_coords[i],  # 起始节点和终止节点的Y坐标                         y_coords[j]],                        color=color,  # 线条颜色                        linestyle=style,  # 线型                        linewidth=width,  # 线条宽度                        alpha=alpha,  # 透明度    # 遍历特征以添加标签    # 定义图例列表    legs = [        # 节点图例        Line2D([0],  # X坐标               [0],  # Y坐标               marker='o',  # 图例的形状               color='w',  # 设置线条边缘颜色               markerfacecolor=net_colors['node_path'],  # 设置标记内部的填充颜色(取自配置中的病理组学颜色)               label='Pathomics',  # 图例中显示的文本标签               ms=15),  # 标记的大小        # 影像组学节点图例        Line2D([0], [0], marker='o', color='w', markerfacecolor=net_colors['node_rad'], label='Radiomics', ms=15),        # 正相关图例        Line2D([0], [0], color=net_colors['edge_pos'], lw=2, label='Pos Correlation'),        # 负相关图例        Line2D([0], [0], color=net_colors['edge_neg'], lw=2, ls='--', label='Neg Correlation')    ]    # 添加图例    ax.legend(handles=legs,  # 图例中显示的句柄列表              loc='upper left',  # 位置              bbox_to_anchor=(-0.11.05),  # 绝对位置坐标              frameon=False,  # 是否显示图例的边框              fontsize=16)  # 字体大小

第十三部分

组合图拼接函数
# =========================================================================================# ====================================== 9.图片拼接函数 ===========================# =========================================================================================def stitch_images(path_left, path_right, scale_right=1.0):    # 打开图片,加载为图像对象    img_left = Image.open(path_left)    img_right = Image.open(path_right)    # 基于左图高度乘以缩放比例,计算右图的新高度    target_height_right = int(img_left.height * scale_right)    # 计算右侧图片的宽高比    aspect_ratio_right = img_right.width / img_right.height    # 根据新的目标高度计算右侧图片的新宽度    new_width_right = int(target_height_right * aspect_ratio_right)    y_left = (canvas_height - img_left.height) // 2    # 粘贴左侧图片    new_img.paste(img_left, (0, y_left))    # 计算右图的垂直居中Y坐标    y_right = (canvas_height - target_height_right) // 2    # 粘贴右侧图片    new_img.paste(img_right_resized, (img_left.width + gap, y_right))

第十四部分

执行部分,数据预处理与模型训练部分,从Excel文件读取数据。分离特征(X)和目标变量(y),并将数据划分为训练集和测试集。使用 StandardScaler 对特征进行标准化处理,并将其转回带有列名的 DataFrame 格式(以便SHAP能识别特征名)。初始化 XGBoost 回归器,设置参数网格,并使用 5 折交叉验证和网格搜索寻找最佳超参数。最后输出找到的最佳参数。SHAP分析与绘图,使用 TreeExplainer 计算测试集的SHAP值。计算每个特征的平均绝对SHAP值(代表全局重要性),并按降序排列,为绘图做准备。根据之前定义的颜色方案和SHAP值的大小,生成对应的颜色映射和每个条形的具体颜色。依次调用之前定义的绘图函数,生成并保存图片。
# =========================================================================================# ======================================10.执行部分=======================================# =========================================================================================if __name__ == '__main__':    # 读取数据    data_df = pd.read_excel(r'data.xlsx')    # 定义目标变量    target_column_name = 'Target_y'    # 提取目标变量数据    y = data_df[target_column_name]    # 提取特征变量数据(删除目标列)    X = data_df.drop(columns=[target_column_name])    # 获取所有特征名称并转换为列表    feature_names = X.columns.tolist()    # 划分训练集和测试集    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)    # 标准化处理    scaler = StandardScaler()    X_train_scaled = scaler.fit_transform(X_train)    X_test_scaled = scaler.transform(X_test)    model = best_model    # 创建SHAP树解释器对象,用于解释模型    explainer = shap.TreeExplainer(model)    # 计算测试集数据的SHAP值    shap_values = explainer(X_test_df)    # 计算所有样本SHAP绝对值的平均值,衡量特征整体重要性    mean_abs_shap = np.abs(shap_values.values).mean(axis=0)    # 创建包含特征重要性数值的Series,索引为特征名    shap_series = pd.Series(mean_abs_shap, index=feature_names)    # 对特征重要性进行降序排序    shap_series.sort_values(ascending=False, inplace=True)    # 获取排序后的特征名称列表    sorted_features = shap_series.index.tolist()    # 获取排序后的特征重要性数值数组    sorted_shap_values = shap_series.values    print(pd.DataFrame(shap_values.values[:5, :3], columns=feature_names[:3]).round(4))    print("\n测试集特征平均重要性 (Mean |SHAP|):")    print(np.round(sorted_shap_values, 4))    # 调用函数绘图    draw_bar_and_radial(sorted_features, sorted_shap_values, bar_colors, cmap, color_norm)    draw_native_beeswarm(shap_values, X_test_df, cmap)    draw_beeswarm_no_labels(shap_values, X_test_df, cmap)    draw_combined_plot(sorted_features, sorted_shap_values, shap_values, bar_colors, cmap, color_norm)    draw_right_part_network(X_test_df, sorted_features, corr_method='spearman')

如何应用到你自己的数据

1.设置SHAP图颜色方案:

SCHEME_ID = 30

2.设置网络图图颜色方案:

SCHEME_ID2  = 30
3.设置绘图结果的保存地址:
plt.savefig(fr'shap_bar_radial{SCHEME_ID}.png',  dpi=208, bbox_inches='tight')
4.设置原始数据的路径:
data_df = pd.read_excel(r'simulated_data.xlsx')
5.设置目标变量:
target_column_name = 'Target_y'
6.设置超参数的网格:
param_grid = {'n_estimators': [100200],}

推荐

期刊图片复现|Python绘制二维偏依赖PDP图
期刊复现|python绘制基于SHAP分析和GAM模型拟合的单特征依赖图
期刊图片复现|python绘制带有渐变颜色shap特征重要性组合图(条形图+蜂巢图)
期刊复现|用Python绘制SHAP特征重要性总览图、依赖图、双特征交互效应SHAP图,解锁XGBoost模型的终极奥秘
期刊图片复现|Python绘制shap重要性蜂巢图+单特征依赖图+交互效应强度气泡图+交互效应依赖图(回归+二分类+分类)

获取方式

公众号中的所有所有的免费代码都已经下架了,都并入到付费部分里了,付费合集代码和数据的购买通道已经开通,全部合集100元,后续将会持续更新,决定购买请后台私信我,注意只会分享练习数据和代码文件,不会提供答疑服务,代码文件中已经包含了每行代码的完整注释,购买前请确保真的需要!!!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 19:41:10 HTTP/2.0 GET : https://f.mffb.com.cn/a/465196.html
  2. 运行时间 : 0.143244s [ 吞吐率:6.98req/s ] 内存消耗:4,574.80kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=fedf93d7ae10b2f7e14823b49033acce
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000814s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001626s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001812s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000635s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001369s ]
  6. SELECT * FROM `set` [ RunTime:0.000624s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001486s ]
  8. SELECT * FROM `article` WHERE `id` = 465196 LIMIT 1 [ RunTime:0.002074s ]
  9. UPDATE `article` SET `lasttime` = 1770550870 WHERE `id` = 465196 [ RunTime:0.010774s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000597s ]
  11. SELECT * FROM `article` WHERE `id` < 465196 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.002114s ]
  12. SELECT * FROM `article` WHERE `id` > 465196 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001128s ]
  13. SELECT * FROM `article` WHERE `id` < 465196 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.009081s ]
  14. SELECT * FROM `article` WHERE `id` < 465196 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.007730s ]
  15. SELECT * FROM `article` WHERE `id` < 465196 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.011578s ]
0.147105s