Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

eurobios-mews-labs/survival-data-handler

Repository files navigation

code coveragePyPI version

The aim of this package is to facilitate the use of survival data by switching from temporal data in the form of acollection of survival functions to temporal matrices calculating other functions derived from survival analysis,such as residual life, hazard function, etc. analysis, such as residual life expectancy, hazard function, etc.

Install

pip install survival-data-handler

Usage

importpandasaspdfromlifelinesimportCoxPHFitterfromlifelines.datasetsimportload_rossirossi=load_rossi()cph=CoxPHFitter()cph.fit(rossi,duration_col='week',event_col='arrest')curves=cph.predict_survival_function(rossi).Tcurves.columns=pd.to_timedelta(curves.columns.to_numpy()*7,unit="D")print(curves.head())
7 days 00:00:0014 days 00:00:0021 days 00:00:0028 days 00:00:0035 days 00:00:0042 days 00:00:0049 days 00:00:0056 days 00:00:0063 days 00:00:0070 days 00:00:00
00.9976160.995230.9928480.9904680.9880850.9856990.9833050.9714020.9666140.964223
10.9936950.9874110.9811620.9749410.9687390.9625520.956370.9260010.9139580.907978
20.9940830.9881830.9823140.9764680.9706390.964820.9590040.9304020.9190430.913399
30.9990450.9980890.9971330.9961760.9952160.9942540.9932870.988460.9865080.985531
40.9976260.995250.9928780.9905070.9881350.9857580.9833740.971520.9667520.96437
fromsurvival_data_handlerimportLifespanage=pd.to_timedelta(rossi["age"]*365.25,unit="D")birth=pd.to_datetime('2000')rossi["index"]=rossi.indexbirth=pd.to_datetime('2000')lifespan=Lifespan(curves,index=rossi["index"],birth=birth,age=age,window=(pd.to_datetime("2000"),pd.to_datetime("2001")))

We now add the supervision data (in the form of duration)

lifespan.add_supervision(event=rossi["arrest"],# True if the data is observed False, when censoreddurations=rossi["duration"]+birth# The duration)

Let's calculate the associated performance

lifespan.assess_metric("survival_function")
DatePerformance (1 - AUC)
2000-01-310.468458
2000-03-010.384425
2000-03-310.432012
2000-04-300.357338
2000-05-300.365263
2000-06-290.365190
2000-07-290.371438
2000-08-280.343447
2000-09-270.340607
2000-10-270.344628
2000-11-260.334398
2000-12-260.334444

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp