当前位置: 首页>>代码示例>>Python>>正文


Python AalenAdditiveFitter.predict_median方法代码示例

本文整理汇总了Python中lifelines.estimation.AalenAdditiveFitter.predict_median方法的典型用法代码示例。如果您正苦于以下问题:Python AalenAdditiveFitter.predict_median方法的具体用法?Python AalenAdditiveFitter.predict_median怎么用?Python AalenAdditiveFitter.predict_median使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lifelines.estimation.AalenAdditiveFitter的用法示例。


在下文中一共展示了AalenAdditiveFitter.predict_median方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_aalen_additive_median_predictions_split_data

# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import predict_median [as 别名]
    def test_aalen_additive_median_predictions_split_data(self):
        # This tests to make sure that my median predictions statisfy
        # the prediction are greater than the actual 1/2 the time.
        # generate some hazard rates and a survival data set
        n = 2500
        d = 5
        timeline = np.linspace(0, 70, 5000)
        hz, coef, X = generate_hazard_rates(n, d, timeline)
        T = generate_random_lifetimes(hz, timeline)
        X['T'] = T
        # fit it to Aalen's model
        aaf = AalenAdditiveFitter()
        aaf.fit(X, 'T')

        # predictions
        T_pred = aaf.predict_median(X[list(range(6))])
        assert abs((T_pred.values > T).mean() - 0.5) < 0.05
开发者ID:nerdless,项目名称:lifelines,代码行数:19,代码来源:test_estimation.py

示例2: test_swapping_order_of_columns_in_a_df_is_okay

# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import predict_median [as 别名]
    def test_swapping_order_of_columns_in_a_df_is_okay(self, rossi):
        aaf = AalenAdditiveFitter()
        aaf.fit(rossi, event_col='arrest', duration_col='week')

        misorder = ['age', 'race', 'wexp', 'mar', 'paro', 'prio', 'fin']
        natural_order = rossi.columns.drop(['week', 'arrest'])
        deleted_order = rossi.columns - ['week', 'arrest']
        assert_frame_equal(aaf.predict_median(rossi[natural_order]), aaf.predict_median(rossi[misorder]))
        assert_frame_equal(aaf.predict_median(rossi[natural_order]), aaf.predict_median(rossi[deleted_order]))

        aaf = AalenAdditiveFitter(fit_intercept=False)
        aaf.fit(rossi, event_col='arrest', duration_col='week')
        assert_frame_equal(aaf.predict_median(rossi[natural_order]), aaf.predict_median(rossi[misorder]))
        assert_frame_equal(aaf.predict_median(rossi[natural_order]), aaf.predict_median(rossi[deleted_order]))
开发者ID:DGaffney,项目名称:lifelines,代码行数:16,代码来源:test_estimation.py

示例3: range

# 需要导入模块: from lifelines.estimation import AalenAdditiveFitter [as 别名]
# 或者: from lifelines.estimation.AalenAdditiveFitter import predict_median [as 别名]
#Go through each training testing monteCarlo sampling and train/predict
predictions=[]
for i in range(trainLabels.shape[1]):
    X = patsy.dmatrix('age + grade + stage -1', clinical, return_type='dataframe')
    X['T'] = clinical['OS_OS']
    X['C'] = clinical['OS_vital_status']
    
    trainX = X.ix[trainLabels[i],:].reset_index()
    testX = X.ix[testLabels[i],:].reset_index()

    #Build model and train
    aaf = AalenAdditiveFitter(penalizer=1., fit_intercept=True)
    aaf.fit(trainX.drop(['index'], axis=1), duration_col='T', event_col='C',show_progress=False)
    #Predict on testing data
    median = aaf.predict_median(testX.drop(['T','C', 'index'], axis=1))
    median.index = testX['index']
    predictions.append(median.replace([np.inf, -np.inf, np.nan], 0))


# ###Saving Results to Synapse and ask Synapse to evaluate our predictions
# To document what we have done we will start by storing this code in Synapse as a file Entity.

# In[34]:

codeEntity = synapseclient.File('tcga_survival_analysis.py', parentId='syn1720423')
codeEntity = syn.store(codeEntity)


# We then save the predictions we made to a file and create a file Entity for it.
开发者ID:Sage-Bionetworks,项目名称:synapseTutorials,代码行数:31,代码来源:tcga_survival_analysis.py


注:本文中的lifelines.estimation.AalenAdditiveFitter.predict_median方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。