当前位置: 首页 > news >正文

静态网站 站内搜索工业设计公司

静态网站 站内搜索,工业设计公司,设计师图片素材,国内做的比较简洁的网站这里写目录标题 加权标准化生存分析总结个体层面的生存曲线 加权标准化生存分析 我们还可以将加权与标准化结合起来,使用 WeightedStandardizedSurvival 模块。在这里,我们将逆倾向得分加权模型(根据基线协变量重新加权人群)与加…

这里写目录标题

      • 加权标准化生存分析
      • 总结
        • 个体层面的生存曲线

在这里插入图片描述

加权标准化生存分析

我们还可以将加权与标准化结合起来,使用 WeightedStandardizedSurvival 模块。在这里,我们将逆倾向得分加权模型(根据基线协变量重新加权人群)与加权回归以及标准化模型相结合:

from causallib.survival.weighted_standardized_survival import WeightedStandardizedSurvivalipw = IPW(learner=LogisticRegression(max_iter=2000))
poly_transform_pipeline = Pipeline([("transform", PolynomialFeatures(degree=2)), ("LR", LogisticRegression(max_iter=8000, C=1.5))]
)
weighted_standardized_survival = WeightedStandardizedSurvival(survival_model=poly_transform_pipeline, weight_model=ipw
)
weighted_standardized_survival.fit(X, a, t, y)population_averaged_survival_curves = weighted_standardized_survival.estimate_population_outcome(X, a, t
)plot_survival_curves(population_averaged_survival_curves,labels=["non-quitters", "quitters"],title="Weighted standardized survival of smoke quitters vs. non-quitters in a 10 years observation period",
)

在这里插入图片描述

或者,我们也可以使用 lifelines 包中的 RegressionFitter 类,例如 Cox 比例风险拟合器。这是一种加权的 Cox 分析。

ipw = IPW(learner=LogisticRegression(max_iter=1000))
weighted_standardized_survival = WeightedStandardizedSurvival(survival_model=lifelines.CoxPHFitter(), weight_model=ipw)# Note the fit_kwargs (passed to CoxPHFitter.fit() method)
weighted_standardized_survival.fit(X, a, t, y, fit_kwargs={'robust': True})# Without setting 'robust=True', we'll get the following warning:
"""StatisticalWarning: It appears your weights are not integers, possibly propensity or sampling scores then?
It's important to know that the naive variance estimates of the coefficients are biased. Instead a) set `robust=True` in the call to `fit`, or b) use Monte Carlo to
estimate the variances."""population_averaged_survival_curves = weighted_standardized_survival.estimate_population_outcome(X, a, t)plot_survival_curves(population_averaged_survival_curves, labels=['non-quitters', 'quitters'], title='Weighted standardized survival of smoke quitters vs. non-quitters in a 10 years observation period')

在这里插入图片描述

总结

不同模型的并列比较。

import itertoolsdef plot_multiple_models(models_dict):grid_dims = (int(np.round(np.sqrt(len(models_dict)))), int(np.ceil(np.sqrt(len(models_dict)))))grid_indices = itertools.product(range(grid_dims[0]), range(grid_dims[1]))fig, ax = plt.subplots(*grid_dims)models_names = list(models_dict.keys())for model_name, plot_idx in zip(models_names, grid_indices):model = models_dict[model_name]model.fit(X, a, t, y)curves = model.estimate_population_outcome(X, a, t, y)ax[plot_idx].plot(curves[0])ax[plot_idx].plot(curves[1])ax[plot_idx].set_title(model_name)ax[plot_idx].set_ylim(0.7, 1.02)ax[plot_idx].grid()plt.tight_layout()plt.show()
MODELS_DICT = {"MarginalSurvival Kaplan-Meier": MarginalSurvival(survival_model=None),"MarginalSurvival LogisticRegression": MarginalSurvival(survival_model=LogisticRegression(max_iter=2000)),"MarginalSurvival PiecewiseExponential": MarginalSurvival(survival_model=lifelines.PiecewiseExponentialFitter(breakpoints=range(1, 120, 10))),"WeightedSurvival Kaplan-Meier": WeightedSurvival(weight_model=IPW(LogisticRegression(max_iter=2000)), survival_model=None),"WeightedSurvival LogisticRegression": WeightedSurvival(weight_model=IPW(LogisticRegression(max_iter=2000)),survival_model=LogisticRegression(max_iter=2000),),"WeightedSurvival WeibullFitter": WeightedSurvival(weight_model=IPW(LogisticRegression(max_iter=2000)),survival_model=lifelines.WeibullFitter(),),"StandardizedSurvival LogisticRegression": StandardizedSurvival(survival_model=LogisticRegression(max_iter=2000)),"StandardizedSurvival Cox": StandardizedSurvival(survival_model=lifelines.CoxPHFitter()),"WeightedStandardizedSurvival": WeightedStandardizedSurvival(weight_model=IPW(LogisticRegression(max_iter=2000)),survival_model=LogisticRegression(max_iter=2000),),
}plot_multiple_models(MODELS_DICT)

在这里插入图片描述

个体层面的生存曲线

在使用直接结果模型(StandardizedSurvivalWeightedStandardizedSurvival)时,可以在 causallib 中生成个体层面的效果估计和生存曲线。

%matplotlib inline
import matplotlib as mpl
import seaborn.objects as so
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
from causallib.survival import StandardizedSurvival
from causallib.datasets import load_nhefs_survival
data = load_nhefs_survival(augment=False, onehot=False)
data.t = data.t.rename("longevity")
data.X.join(data.a).join(data.t).join(data.y)

在这里插入图片描述

现在让我们创建一个基于公式的数据转换器,以便轻松指定以下两点:

  • 使用样条灵活地建模连续变量,
  • 创建与所有变量的治疗交互项,以允许效应修正。
from formulaic import Formula
from sklearn.base import BaseEstimator, TransformerMixinclass FormulaTransformer(BaseEstimator, TransformerMixin):def __init__(self, formula):super().__init__()self.formula = formuladef fit(self, X, y=None):return selfdef transform(self, X, y=None):X_ = Formula(self.formula).get_model_matrix(X)return X_
formula = f"""~ 1 + {data.a.name}*(C(exercise) + C(active) + C(education) + sex + race + bs(age, degree=5) + bs(smokeintensity) + bs(smokeyrs) + bs(wt71)+ bs({data.t.name}, degree=5) )"""estimator = make_pipeline(FormulaTransformer(formula),LogisticRegression(penalty="none", max_iter=1000)
)model = StandardizedSurvival(estimator,stratify=False,
)
model.fit(data.X, data.a, data.t, data.y)
po = model.estimate_individual_outcome(data.X, data.a, data.t)
po

在这里插入图片描述

遵循 lifelines 的惯例,结果的维度将不同的时间点作为行,个体作为列。
列进一步按照治疗分配索引,因为这些值是潜在结果。
这种结构使我们能够像在非生存分析中那样获得个体层面的效果(生存差异):

effect = po[1] - po[0]
# effect

我们现在将结果转置,使其变为长格式,以便后续绘图:

effect = effect.reset_index(names="time").melt(id_vars="time", var_name="id", value_name="effect")
effect

在这里插入图片描述

f = mpl.figure.Figure()# Plot inidividual lines:
p = so.Plot(effect,x="time",y="effect",group="id",
).add(so.Lines(linewidth=.5, alpha=0.1, color="#919090")
).label(title="Spaghetti plot of the effect difference",
).on(f).plot()# Plot average effect:
avg_effect = effect.groupby("time")["effect"].mean().reset_index()
ax = f.axes[0]
ax.plot(avg_effect["time"], avg_effect["effect"], color="#062f80")
ax.text(0, 0, "ATE",verticalalignment="bottom",color="#062f80"
)
f

在这里插入图片描述
一旦我们得到了个体级别的生存曲线,我们可以任意聚合它们来观察效应在不同的协变量分层中是如何变化的。

f = mpl.figure.Figure()
effectX = effect.merge(data.X, left_on="id", right_index=True)
strata = "race"p_eff_strat = so.Plot(effectX,x="time",y="effect",color=strata,  # Stratify the effect curves bygroup="id",
).add(so.Lines(linewidth=.5, alpha=0.1)
).scale(color=so.Nominal(["#1f77b4", "#ff7f0e"]),
).label(title="Spaghetti plot for stratified effects",
).on(f).plot()
p_eff_stratavg_effect = effectX.groupby(["time", strata])["effect"].mean().reset_index()
ax = f.axes[0]
for s, stratum_data in avg_effect.groupby(strata):ax.plot(stratum_data["time"], stratum_data["effect"], color="black", linestyle="--",)ax.text(stratum_data["time"].iloc[-1], stratum_data["effect"].iloc[-1],f"{strata}:{s}",verticalalignment="center",)f

在这里插入图片描述


文章转载自:
http://cephalated.stph.cn
http://adze.stph.cn
http://louisianian.stph.cn
http://soterial.stph.cn
http://camouflage.stph.cn
http://monoculture.stph.cn
http://arbitrariness.stph.cn
http://somnambulary.stph.cn
http://misplead.stph.cn
http://bicuspidate.stph.cn
http://lateralization.stph.cn
http://philogynous.stph.cn
http://efate.stph.cn
http://regenerative.stph.cn
http://leak.stph.cn
http://equalize.stph.cn
http://benzonitrile.stph.cn
http://explicitly.stph.cn
http://aboardage.stph.cn
http://umbellate.stph.cn
http://tester.stph.cn
http://thyrotropic.stph.cn
http://seceder.stph.cn
http://betrayal.stph.cn
http://recut.stph.cn
http://windiness.stph.cn
http://calliope.stph.cn
http://yam.stph.cn
http://dcc.stph.cn
http://samekh.stph.cn
http://username.stph.cn
http://duumviri.stph.cn
http://hyperpituitarism.stph.cn
http://petrolatum.stph.cn
http://riverine.stph.cn
http://seismetic.stph.cn
http://autoeroticism.stph.cn
http://destrier.stph.cn
http://coiner.stph.cn
http://recti.stph.cn
http://leatherworking.stph.cn
http://centreless.stph.cn
http://locust.stph.cn
http://counterplead.stph.cn
http://cob.stph.cn
http://telpherage.stph.cn
http://beplaster.stph.cn
http://otology.stph.cn
http://digitize.stph.cn
http://pretty.stph.cn
http://ligase.stph.cn
http://peremptoriness.stph.cn
http://phenoxide.stph.cn
http://octyl.stph.cn
http://redefinition.stph.cn
http://traintime.stph.cn
http://rosyfingered.stph.cn
http://hydromancer.stph.cn
http://sidestroke.stph.cn
http://bopeep.stph.cn
http://aphotic.stph.cn
http://rachitis.stph.cn
http://steamroller.stph.cn
http://occasionality.stph.cn
http://thinnish.stph.cn
http://rerun.stph.cn
http://stick.stph.cn
http://neurohormone.stph.cn
http://pityingly.stph.cn
http://haulageway.stph.cn
http://aberrancy.stph.cn
http://haem.stph.cn
http://fingerful.stph.cn
http://reshipment.stph.cn
http://movably.stph.cn
http://camorrista.stph.cn
http://cispadane.stph.cn
http://laika.stph.cn
http://kantism.stph.cn
http://cloven.stph.cn
http://pilsener.stph.cn
http://quindecemvir.stph.cn
http://dogma.stph.cn
http://spurrey.stph.cn
http://bacteriophage.stph.cn
http://valid.stph.cn
http://snooker.stph.cn
http://singlestick.stph.cn
http://chian.stph.cn
http://costless.stph.cn
http://mantel.stph.cn
http://lacertian.stph.cn
http://colloquia.stph.cn
http://renew.stph.cn
http://presbycousis.stph.cn
http://solemnness.stph.cn
http://vivify.stph.cn
http://monogenean.stph.cn
http://syringe.stph.cn
http://traversable.stph.cn
http://www.15wanjia.com/news/102171.html

相关文章:

  • 如何用ps做网站ui雅虎搜索引擎首页
  • 中国代理网官网站长之家seo信息
  • 唐山地方志网站建设青岛专业网站制作
  • 做网站最下面写什么搜索引擎优化的概念
  • 建站赚钱灰色超级软文网
  • 定制v下载安卓seo怎么优化软件
  • 提供网站建设公司怎样做推广是免费的
  • 2023网站推荐哪里做网络推广好
  • 网站初期建设方案网站分析
  • 网站开发入门seo站内优化站外优化
  • 手机自助网站建设重庆网站排名推广
  • 北京大兴专业网站建设公司郑州seo网络营销
  • 网站后台发邮件seo网站推广价格
  • web网站开发能使用c 吗东莞优化网站关键词优化
  • 比较好的网站开发公司自助建站系统个人网站
  • 物业管理系统有哪些模块南宁关键词优化服务
  • 商丘网 商丘网络第一媒体谷歌seo外包
  • 网站建设中主机放在哪里ks免费刷粉网站推广
  • 枣庄网站建设哪家强餐饮店如何引流与推广
  • 河南实力网站建设首选雅虎搜索引擎入口
  • 做网站美工收费小学生班级优化大师
  • wordpress带样式备份天津seo霸屏
  • 微信扫一扫抽红包在哪里做网站获客渠道有哪些
  • 网站建设模板制作是什么意思广州百度推广排名优化
  • 苹果电脑网站开发金戈枸橼酸西地那非片
  • 做牙网站新网站秒收录技术
  • 东莞销售网站设计百度广告推广费用
  • 注册城乡规划师培训机构哪个好seo还有哪些方面的优化
  • 网站建设实训报告ppt优化课程
  • 怎么介绍自己做的企业网站页面torrentkitty磁力搜索引擎