Python简单Nomo库的使用指南

一、故事开始

1、故事从这里开始:使用python绘制列线图

2、进而追踪到 ​​​​​​https://spj.science.org/doi/10.34133/hds.0023

simpleNomo: A Python Package of Making Nomograms for Visualizable Calculation of Logistic Regression Models

3、然后找到了 https://github.com/Hhy096/nomogram

4、最后发现了简单使用的在线平台 https://visdata.bjmu.edu.cn/nomogram

二、simpleNomo介绍

1、列线图

随着20世纪60年代中期数据可视化浪潮的兴起,列线图继续发展完善,当前已能整合多因素回归模型(Logistic回归、Cox回归、线性回归等)中各个预测指标对结局变量的影响,并根据影响程度的高低(回归系数的大小)对各预测指标的每个取值水平进行赋分,继而再将各个评分相加得到总评分,最终通过总评分与结局事件发生概率之间的函数转换关系实现对结局事件发生概率的个体化预测。

2、simpleNomo

simpleNomo是一个开源的Python工具箱,可以为逻辑回归模型构建nomogram。独特的是,simpleNomo允许仅使用模型的系数创建nomogram。此外,还提供了一个在线网站(https://visdata.bjmu.edu.cn/nomogram),用于nomogram生成。

三、simpleNomo工具箱背景

Logistic regression models are widely used in clinical prediction, but their application in resource-poor settings or areas without internet access can be challenging. Nomograms can serve as a useful visualization tool to speed up the calculation procedure, but existing nomogram generators often require the input of raw data, inhibiting the transformation of established logistic regression models that only provide coefficients. Developing a tool that can generate nomograms directly from logistic regression coefficients would greatly increase usability and facilitate the translation of research findings into patient care.

逻辑回归模型广泛用于临床预测,但其在资源贫乏环境或没有互联网接入的地区的应用可能具有挑战性。图可以作为一种有用的可视化工具来加速计算过程,但现有的图生成器通常需要输入原始数据,这抑制了仅提供系数的已建立的逻辑回归模型的转换。开发一种可以直接从逻辑回归系数生成诺图的工具将大大提高可用性,并促进将研究结果转化为患者护理。

四、本地使用问题解决

1、字体不存在,比较懒直接使用已有字体,sans-serif

2、使用 fig.tight_layout() 绘图报错

\python\Lib\site-packages\simpleNomo\__init__.py:346: UserWarning: Tight layout not applied. tight_layout cannot make axes height small enough to accommodate all axes decorations.

解决:将 fig.tight_layout() 修改为:
plt.savefig('fig.png', bbox_inches ='tight')

3、\python\Lib\site-packages\simpleNomo\__init__.py:281: FutureWarning: Calling float on a single element Series is deprecated and will raise a TypeError in the future. Use float(ser.iloc[0]) instead
  maxi = float(d["max"])

解决:maxi = float(d["max"]) 修改为  maxi = float(d["max"].iloc[0])

五、参考网站

[1] Haoyang Hong, Shenda Hong. simpleNomo: A Python Package of Making Nomograms for Visualizable Calculation of Logistic Regression Models. Health Data Sci. 2023;3:0023.DOI:10.34133/hds.0023

[2] 使用python绘制列线图​​​​​​

六、后续追踪路径

列线图怎么用python绘制 列线图的基本原理_mob6454cc70cb6b的技术博客_51CTO博客

仅供学习,侵权联系删除,谢谢。

物联沃分享整理
物联沃-IOTWORD物联网 » Python简单Nomo库的使用指南

发表评论