### 特征分析 import simplestart as ss import pandas as pd ss.md(''' ## 特征分析 ''') ss.space() ss.md("#### 1. 特征的散点矩阵") ss.space() ss.image("./images/feature01.png", width=600, height = 500) ss.space() ss.md(''' 本图来自: [VuNus 【机器学习基础】1.7 鸢尾花分类](https://blog.csdn.net/qq_47809408/article/details/124632290) ''') ss.space() ss.md("#### 2. 特征浏览") import pandas as pd from bokeh.plotting import figure, show from bokeh.models import ColumnDataSource from bokeh.transform import factor_cmap from bokeh.embed import file_html from bokeh.resources import CDN from bokeh.palettes import Category10 # 加载数据集 data = pd.read_csv("./data/iris.csv") # 创建 Bokeh 图表 p = figure(title="Iris 数据集散点图", x_axis_label='花瓣长度 (cm)', y_axis_label='花瓣宽度 (cm)', tools="pan,wheel_zoom,box_zoom,reset,hover,save", width=800, height=600) # 创建数据源 source = ColumnDataSource(data) # 为 species 列设置颜色映射 species_list = data['species'].unique().tolist() p.circle(x='petal_length', y='petal_width', source=source, size=10, color=factor_cmap('species', palette=Category10[3], factors=species_list), legend_field='species') # 配置图例 p.legend.title = "Species" p.legend.location = "top_left" # 将 Bokeh 图表转换为 HTML 并显示 html_output = file_html(p, CDN, "Iris 数据集散点图") #show(p) ss.htmlview(html_output)