Survival Analysis - nonparametric model

Example A.11. Example of the nonparametric survival model

#------ data loading ------

table "HIV":
    censor days dose treatment weight
    
    N 30.0 3.081430851090935 0.0 57.8738112449646
    Y 33.0 2.2284185921454207 1.0 46.98548197746277
    N 36.0 2.793160256900953 1.0 40.64843571186066
    N 31.0 2.3161954166339696 1.0 40.122660636901855
    N 50.0 3.1277873810530066 0.0 47.098684549331665
    Y 28.0 2.6280503396985995 1.0 43.85288977622986
    N 36.0 2.437778201298561 1.0 46.10991942882538
    N 37.0 2.714954640472462 1.0 42.934664607048035
    N 30.0 2.825249956361242 0.0 58.074954867362976
    N 39.0 2.444908655624817 0.0 58.468533754348755
    Y 31.0 2.7114104899340448 1.0 39.142784118652344
    N 41.0 2.94848220027547 0.0 44.23114502429962
    N 28.0 2.9645756487077244 1.0 55.35672903060913
    N 41.0 2.290834441296651 1.0 42.474403500556946
    N 63.0 3.0564012778980416 0.0 46.09067142009735
    N 30.0 2.948842929873205 0.0 46.39939904212952
    N 32.0 2.417541672572897 0.0 65.35233283042908
    Y 45.0 3.185570719084413 0.0 45.58563852310181
    Y 30.0 2.7404453142255814 1.0 54.944403529167175
    N 30.0 2.34792207236493 0.0 48.73584043979645
    Y 28.0 2.6066313731805923 0.0 50.85618436336517
    N 33.0 3.147555289426225 1.0 45.98667299747467
    Y 88.0 2.8853177676167308 0.0 35.09775495529175
    N 38.0 2.5345985397824777 0.0 43.1633358001709
    Y 29.0 2.320861461672114 1.0 53.95890474319458
    N 33.0 2.7948169349758176 1.0 57.79575431346893
    Y 32.0 2.5992757005792857 0.0 41.27472746372223
    N 28.0 3.136323450462654 1.0 57.88637900352478
    N 41.0 2.6741280259338156 0.0 52.05712568759918
    N 30.0 2.8173865700918084 1.0 50.10614264011383
    N 28.0 2.2408500642157927 0.0 53.18464469909668
    N 28.0 2.5509714116969633 0.0 52.71421265602112
    N 55.0 2.8213830565294984 0.0 40.885963916778564
    N 32.0 2.4273371494971934 0.0 48.997780203819275
    N 31.0 2.6487828638066757 1.0 52.48666775226593
    N 33.0 2.498272122845316 1.0 41.266563296318054
    N 32.0 2.9660948924938135 1.0 50.418524622917175
    N 36.0 2.7394662336137823 0.0 42.07624423503876
    N 30.0 2.7452705362811454 1.0 62.820916295051575
    N 34.0 3.087627224486434 0.0 47.21555209159851
    N 64.0 2.37063068259187 0.0 54.45838928222656
    N 31.0 2.3214752107658216 0.0 50.81758153438568
    N 36.0 3.0645516154652377 0.0 44.36666679382324
    N 29.0 2.507903009710647 1.0 55.339086294174194
    N 62.0 3.222180386251486 0.0 43.327778458595276
    N 35.0 3.0075439228834555 0.0 38.84279119968414
    N 39.0 3.119852909901356 0.0 41.8588570356369
    Y 82.0 3.0418112274741143 1.0 31.74041712284088
    Y 29.0 3.0952031905202606 0.0 55.899375677108765
    N 30.0 2.428066420544726 1.0 49.83421802520752
    N 43.0 2.7461049250314398 0.0 44.55719482898712
    N 30.0 2.685063480009806 0.0 42.86260807514191
    N 38.0 2.673262196321976 0.0 43.42743194103241
    N 30.0 2.6029907504661254 1.0 61.44343388080597
    N 35.0 2.3166010581839807 1.0 46.22520351409912
    N 32.0 3.0095231192909937 1.0 40.053192257881165
    N 29.0 2.5733932135819324 1.0 53.496418595314026
    N 28.0 2.279215674998498 1.0 42.93415677547455
    N 60.0 2.492899053446145 0.0 44.43672692775726
    N 30.0 2.476461302031735 1.0 48.018630623817444
    Y 37.0 2.8520655533096235 0.0 44.8764009475708
    N 37.0 3.1518045857517154 1.0 49.3680135011673
    N 30.0 2.9153954819696715 1.0 49.525230050086975
    N 32.0 2.637453694206634 1.0 43.58605468273163
    N 31.0 2.4376940380600063 1.0 45.57033693790436
    N 58.0 2.461523257765543 0.0 45.864428758621216
    N 32.0 3.0699319938588903 1.0 56.160651445388794
    N 87.0 2.6465096577784455 0.0 33.01168072223663
    N 29.0 2.295246680407634 1.0 55.48183524608612
    Y 31.0 2.3054889809583967 0.0 47.76137626171112
    N 70.0 2.2985271026542557 0.0 36.922224164009094
    N 29.0 2.4566889312587827 0.0 48.11109435558319
    N 31.0 2.3262493123463654 0.0 42.92390561103821
    N 79.0 3.160247682801543 0.0 45.728721022605896
    N 40.0 2.6820998534275016 0.0 40.03557217121124
    N 32.0 2.4004851865292722 1.0 46.45250082015991
    N 82.0 2.23333776855838 0.0 31.5962792634964
    N 28.0 2.8828017121825145 1.0 37.30770468711853
    N 26.0 2.7895431128242967 1.0 43.97993278503418
    N 36.0 3.001367858915769 0.0 53.60692238807678
    N 33.0 3.213561996595554 1.0 50.63715600967407
    N 30.0 2.771378506406407 1.0 47.741469502449036
    N 30.0 2.753735868832637 0.0 57.45537531375885
    N 30.0 2.3618389146055723 1.0 42.4123272895813
    Y 34.0 2.3200263447155756 1.0 52.94650888442993
    Y 27.0 2.5502785209347234 1.0 56.603357911109924
    N 38.0 3.177853644572297 1.0 37.21322977542877
    Y 52.0 3.2831628197807117 0.0 40.17420041561127
    N 34.0 2.6228052088840226 1.0 43.38765358924866
    Y 39.0 3.055756520792758 1.0 42.641565918922424
    N 32.0 3.00239502396637 0.0 46.75193762779236
    N 86.0 2.4905506830766013 0.0 47.11822819709778
    N 27.0 2.7037077801923677 1.0 51.02326464653015
    Y 38.0 2.597713133947351 1.0 46.52934992313385
    N 34.0 3.001039147303028 1.0 45.40196716785431
    N 30.0 2.6868492495016354 1.0 44.355523109436035
    N 32.0 2.9580542489999537 0.0 38.836639165878296
    Y 87.0 2.4924213929461847 0.0 40.57176160812378
    Y 27.0 3.28069196967279 1.0 46.625693678855896
    N 30.0 2.820234781890454 1.0 44.84109568595886

pd = PhysicalData('HIV')
ld = LogicalData(pd)

fs = SurvivalFunctionSettings()

#----- Nonparametric Survival algorithm settings
as = NonparametricSurvivalSettings()
as.survivalEstimator = NonparametricSurvivalEstimator.lifeTable

fs.algorithmSettings = as


#----- survival function settings
fs.logicalData = ld
fs.targetAttributeName = 'days'
fs.censorName = 'censor'
fs.censoredCategory = 'Y'     # censor category for censored observation

save('hiv_pd', pd)
save('hiv_ld', ld)
save('nonparam_settings', fs)


#----- building the Nonparametric Survival model
bt = MiningBuildTask('hiv_pd', 'nonparam_settings', 'nonparam_model')

save('nonparam_build', bt)
execute('nonparam_build')

print "Build task for survival example was successfully executed"

Output

Build task for survival example was successfully executed