python - 使用 For Loop 运行多个功能/模型属性(python)
问题描述
我正在探索生存模型,即“Cox Proportional-Hazards Model”。我想使用 for 循环来运行模型的多个属性。
attributelist= ['alpha',
'baseline_cumulative_hazard_',
'baseline_estimation_method',
'baseline_hazard_',
'baseline_survival_',
'check_assumptions',
'cluster_col',
'compute_followup_hazard_ratios',
'compute_residuals',
'concordance_index_',
'confidence_intervals_',
'duration_col']
只是 Cox-PH 模型可用的“属性”片段。
由于我仍在学习该模型及其潜在输出,因此我想尝试运行所有内容以查看它抛出了什么。
我想写一些类似的东西:
cph = CoxPHFitter()
cph.fit(df, 'tenure', event_col='event')
--------------------------------------------------
for i in attributelist:
print(cph.i) # Is there a better way to do this instead of printing?
有谁知道我们如何做到这一点?(我知道阅读文档会有所帮助,但作为一个人,我更亲力亲为!)
解决方案
推荐阅读
- google-analytics - 如何计算访问次数最多的页面,不包括 Google Analytics 上的目标页面访问?
- javascript - 多个键的 JSON 过滤运行缓慢
- database - MongoDB - 将两个集合嵌入到一个集合中
- sql-server - 使用内部联接的直接查询和使用内部联接包含另一个选择查询有什么区别?
- c - sbrk 的返回值上下文中的“(void*)-1”是什么?
- python - 熊猫:一对多加入+剩余余额新行:拆分合同与发票
- sql - SQL 数据验证
- ansible - 当带有 var1 的语句包含在 var2 中时(可以这样做吗?)
- php - 如何创建 .json 文件并使用 PHP/Laravel 将数据写入该文件
- text - 如何在记事本++中将字符填充到不同长度的列以获取GPS坐标