220531

编程入门 行业动态 更新时间:2024-10-25 14:34:38

220531

220531

  • 参考连接
    • 使用 Hyperopt 和 Plotly 可视化超参数优化
    • Visualizing Hyperparameter Optimization with Hyperopt and Plotly — States Title

  • 源代码
# plotly express不支持轮廓图,
# 所以我们将使用'graph_objects'来代替。
# `go.Contour`自动为我们的损失插入“z”值。
fig = go.Figure(data=go.Contour(z=trials_df.loc[max_depth_filter, "loss"],x=trials_df.loc[max_depth_filter, "gradient_boosting_regressor__learning_rate"],y=trials_df.loc[max_depth_filter, "gradient_boosting_regressor__n_estimators"],contours=dict(showlabels=True,  # 显示轮廓上的标签labelfont=dict(size=12, color="white",),  # 标签字体属性),colorbar=dict(title="loss", titleside="right",),hovertemplate="loss: %{z}<br>learning_rate: %{x}<br>n_estimators: %{y}<extra></extra>",)
)fig.update_layout(xaxis_title="learning_rate",yaxis_title="n_estimators",title={"text": "learning_rate vs. n_estimators | max_depth == 3","xanchor": "center","yanchor": "top","x": 0.5,},
)
  • 自己修改的代码
import plotly.graph_objs as go
import pandas as pd data = pd.read_excel('Finetune_best2_TPE_Results_SEU_RMS_0_1.xlsx')fig = go.Figure()contour = go.Contour(x=data['params_nSrc'],y=data['params_nTrg'],z=-data['value'],contours=dict(showlabels=True,  # 显示轮廓上的标签labelfont=dict(size=12, color="white",),  # 标签字体属性),colorbar=dict(title="CICSD", titleside="right",),hovertemplate="CICSD: %{z}<br>nSrc: %{x}<br>nTrg: %{y}<extra></extra>",)fig.add_trace(contour)fig.add_trace(go.Scatter(x=data['params_nSrc'], y=data['params_nTrg'], mode='markers', marker=dict(color='white')))
fig.update_layout(showlegend=False)idx_max = data['value'].idxmax()
ns = [data.loc[idx_max, 'params_nSrc']]
nt = [data.loc[idx_max, 'params_nTrg']]
nz = [data.loc[idx_max, 'value']]fig.add_trace(go.Scatter(x=ns, y=nt, mode='markers', marker=dict(color='yellow', symbol='star', size=15, line=dict(color='red',width=1))))fig.update_layout(width = 809,height= 500,margin=dict(l=5,r=5,b=5,t=5,pad=0),xaxis_title="nSrc",yaxis_title="nTrg",paper_bgcolor="white",xaxis=dict(range=[data['params_nSrc'].min(), data['params_nSrc'].max()]),yaxis=dict(range=[data['params_nTrg'].min(), data['params_nTrg'].max()])# title={#     "text": "nSrc vs. nTrg",#     "xanchor": "center",#     "yanchor": "top",#     "x": 0.5,# },
)fig.write_html("HPO_Plotly.html")
fig.write_image("HPO_Plotly.png")

更多推荐

220531

本文发布于:2024-03-06 10:23:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1715081.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!