除了凡科建站还有什么网站吗福建工程建设管理中心网站
除了凡科建站还有什么网站吗,福建工程建设管理中心网站,西安企业自助建站,阿里云网站建设流程教案浙大疏锦行
官方文档的检索方式#xff1a;GitHub和官网
官方文档的阅读和使用#xff1a;要求安装的包和文档为同一个版本
类的关注点#xff1a;
a.实例化所需要的参数
b.普通方法所需要的参数
c.普通方法的返回值
绘图的理解#xff1a;对底层库的调用
import p…浙大疏锦行官方文档的检索方式GitHub和官网官方文档的阅读和使用要求安装的包和文档为同一个版本类的关注点a.实例化所需要的参数b.普通方法所需要的参数c.普通方法的返回值绘图的理解对底层库的调用import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.datasets import load_iris from pdpbox.info_plots import InteractTargetPlot # 导入核心类 # 1. 全局配置 数据准备 # 解决中文显示问题matplotlib引擎 plt.rcParams[font.sans-serif] [SimHei] plt.rcParams[axes.unicode_minus] False # 加载鸢尾花数据集并格式化 iris load_iris() iris_df pd.DataFrame( datanp.c_[iris.data, iris.target], columns[ sepal_length, sepal_width, petal_length, petal_width, target ] ) # 目标变量为整数0/1/2对应3类鸢尾花无需额外编码 # 2. 初始化 InteractTargetPlot 类 # 核心分析花瓣长度花瓣宽度的交互与目标类别的关系 interact_target_plot InteractTargetPlot( dfiris_df, # 包含特征和目标的DataFrame features[petal_length, petal_width], # 待分析的两个交互特征列名 feature_names[花瓣长度 (cm), 花瓣宽度 (cm)], # 特征显示名称用于绘图标注 targettarget, # 目标变量列名 num_grid_points10, # 每个特征的网格点数分箱数默认10 grid_typespercentile, # 网格划分方式percentile分位数/ equal等距 percentile_rangesNone, # 分位数范围None0-100% grid_rangesNone, # 自定义网格范围如[[0,7],[0,3]] cust_grid_pointsNone, # 自定义网格点优先级高于num_grid_points show_outliersFalse, # 是否显示异常值 endpointsTrue # 是否包含网格端点 ) # 3. 绘制交互目标图Matplotlib引擎 # 适配多分类任务绘制所有类别也可指定which_classes[0,1]仅绘前两类 fig, axes, summary_df interact_target_plot.plot( which_classesNone, # 绘制所有类别0/1/2 show_percentileTrue, # 显示特征分位数标注 figsize(14, 10), # 图表尺寸 dpi300, # 分辨率仅matplotlib生效 ncols2, # 子图列数多分类时自动分栏 annotateTrue, # 标注每个网格点的详细信息样本数/均值 plot_params{ # 自定义绘图样式 cmap: viridis, # 配色方案 title_fontsize: 16, label_fontsize: 12, tick_fontsize: 10 }, enginematplotlib, # 绘图引擎matplotlib/plotly templateplotly_white # plotly模板仅plotly生效 ) # 调整布局并保存/显示 plt.tight_layout() plt.savefig(iris_interact_target_matplotlib.png, bbox_inchestight) plt.show() # 4. 扩展Plotly引擎交互式图表 # Plotly引擎生成可交互图表支持缩放/悬停查看详情 fig_plotly, _, summary_df_plotly interact_target_plot.plot( which_classes[0, 1, 2], # 显式指定绘制所有3类 show_percentileTrue, figsize(14, 10), annotateTrue, plot_params{ color_continuous_scale: RdBu_r }, engineplotly, # 切换为plotly交互式引擎 templateplotly_dark # plotly深色模板 ) # 显示Plotly图表Jupyter/浏览器中可交互 fig_plotly.show() # 保存Plotly图表为HTML fig_plotly.write_html(iris_interact_target_plotly.html) # 5. 查看统计结果 print( 交互特征网格统计摘要 ) print(summary_df.head(10)) # 输出每个网格的目标变量统计均值/样本数等 print(f\n目标类别数{interact_target_plot.n_classes}) # 查看推断的类别数3 print(f特征列名{interact_target_plot.feature_cols}) # 查看特征列名