Survival analysis is a statistical method used to analyze the expected duration of time until one or more events happen, such as death in biological organisms and failure in mechanical systems. This type of analysis is particularly useful in medical research, engineering, and social sciences.

In this tutorial, we’ll explore how to perform survival analysis using the Techtonique API. We’ll work with two datasets:

  • The German Breast Cancer Study Group 2 (GBSG2) dataset
  • The Kidney dataset

We’ll demonstrate how to:

  1. Make API calls using curl (and other programming languages)
  2. Generate survival curves (including prediction intervals) in Python using different Machine learning methods
  3. Compare survival probabilities between different patients in Python

Let’s get started by downloading our datasets and making our first API call.

0 - Download data

!wget https://raw.githubusercontent.com/Techtonique/datasets/refs/heads/main/tabular/survival/gbsg2_2.csv
!wget https://raw.githubusercontent.com/Techtonique/datasets/refs/heads/main/tabular/survival/kidney.csv

1 - Using curl

First, get a token from: https://www.techtonique.net/token.

Note that you can use https://curlconverter.com/ to translate the following request in your favorite programming language.

!curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-F "file=@kidney.csv;type=text/csv" \
"https://www.techtonique.net/survivalcurve?method=km"
{"times":[2.0,4.0,5.0,6.0,7.0,8.0,9.0,12.0,13.0,15.0,16.0,17.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,30.0,34.0,38.0,39.0,40.0,43.0,46.0,53.0,54.0,58.0,63.0,66.0,70.0,78.0,96.0,108.0,113.0,114.0,119.0,130.0,132.0,141.0,149.0,152.0,154.0,156.0,159.0,177.0,185.0,190.0,196.0,201.0,245.0,292.0,318.0,333.0,402.0,447.0,511.0,536.0,562.0],"survival_probabilities":[0.9868421052631579,0.9868421052631579,0.9868421052631579,0.9868421052631579,0.9590437361008154,0.9312453669384729,0.9169185151394196,0.8882648115413128,0.8739379597422593,0.8448066944175173,0.8302410617551463,0.8154153285095187,0.8005895952638911,0.7854841312023082,0.7703786671407253,0.7549710937979108,0.7392425293437876,0.7235139648896645,0.7077854004355413,0.6448711426190487,0.6291425781649255,0.6134140137108023,0.5976854492566791,0.581956884802556,0.566228320348433,0.566228320348433,0.5500503683384778,0.5500503683384778,0.533382175358524,0.51671398237857,0.5000457893986162,0.5000457893986162,0.48280283114349154,0.46555987288836687,0.46555987288836687,0.46555987288836687,0.4469374779728322,0.42831508305729754,0.40969268814176285,0.3910702932262282,0.3724478983106935,0.3724478983106935,0.33324285638325213,0.3136403354195314,0.2940378144558107,0.2940378144558107,0.27303511342325276,0.25203241239069485,0.23102971135813694,0.21002701032557902,0.18902430929302114,0.16802160826046322,0.1470189072279053,0.12601620619534742,0.10501350516278952,0.08401080413023163,0.06300810309767371,0.04200540206511581,0.021002701032557906,0.0],"lower_bound":[0.9102553109267459,0.9102553109267459,0.9102553109267459,0.9102553109267459,0.8783094603652322,0.8426122174685124,0.8242852019907436,0.7888341667037795,0.7715955664880945,0.7371072220745135,0.7202424697504548,0.7031818232846035,0.6863446966653962,0.6692821407981255,0.6524290431612817,0.6353201691306911,0.6179396029435383,0.600766952221238,0.5837876045897149,0.5175887126537961,0.501428890533292,0.48541324827274046,0.46953746121430484,0.45379790888446325,0.4381915934086143,0.4381915934086143,0.42215113184357683,0.42215113184357683,0.4056421189555767,0.3893007306550252,0.37312389775812754,0.37312389775812754,0.3564029597193025,0.3398699645608237,0.3398699645608237,0.3398699645608237,0.3218323705853136,0.30405511656865314,0.2865346991473782,0.2692692944768051,0.25225871014379764,0.25225871014379764,0.21679278606980396,0.19954942220101346,0.18264013482404035,0.18264013482404035,0.1645274238943602,0.14689232612982656,0.12975301412650406,0.1131351703821566,0.09707385136784838,0.08161633322854538,0.06682654409885397,0.05279221487813534,0.039637008241833256,0.027542531139939947,0.01679208899904062,0.00786908624614294,0.0017150505311993823,0.0],"upper_bound":[0.9981359972257208,0.9981359972257208,0.9981359972257208,0.9981359972257208,0.9866128777383311,0.9708048016896479,0.9618157052393598,0.9425317871753408,0.9323728818964988,0.9109697137263687,0.899904851447792,0.8884763999537109,0.8768457976501994,0.8648589323229849,0.8526900734704261,0.8401623217235352,0.8272636042197831,0.8141957681239268,0.8009676532222794,0.7465892181712186,0.7326545907259948,0.7185920973665509,0.7044048145487647,0.690095344841944,0.6756658589291663,0.6756658589291663,0.6607945343186838,0.6607945343186838,0.6454449921255175,0.6299564629168295,0.6143301237450786,0.6143301237450786,0.5981519629753712,0.5818208939410109,0.5818208939410109,0.5818208939410109,0.5643573897967261,0.5466951722133224,0.5288338025067468,0.5107718445919868,0.49250683875975637,0.49250683875975637,0.4539092141443016,0.4342257363301834,0.4142753605771428,0.4142753605771428,0.3930577429935252,0.3714694433520813,0.34949101981707487,0.32709722167473304,0.3042554459039903,0.2809234582974302,0.25704596733927315,0.23254934629068258,0.2073333016806911,0.18125763912628218,0.15412324485059997,0.1256694697451091,0.09599962183907555,0.0]}

Use https://curlconverter.com/ to translate the following request in your favorite programming language.

!curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-F "file=@gbsg2_2.csv;type=text/csv" \
"https://www.techtonique.net/survivalcurve?method=RidgeCV&patient_id=0"
{"times":[8.0,16.0,29.0,46.0,71.0,72.0,98.0,114.0,148.0,171.0,175.0,177.0,195.0,223.0,229.0,233.0,238.0,242.0,249.0,251.0,273.0,285.0,293.0,296.0,305.0,308.0,316.0,319.0,329.0,343.0,358.0,359.0,368.0,370.0,371.0,372.0,417.0,424.0,426.0,432.0,448.0,456.0,460.0,463.0,473.0,475.0,476.0,481.0,490.0,491.0,495.0,498.0,502.0,536.0,542.0,544.0,545.0,546.0,547.0,550.0,552.0,554.0,566.0,571.0,573.0,578.0,594.0,595.0,596.0,598.0,612.0,624.0,628.0,629.0,648.0,650.0,651.0,652.0,663.0,670.0,675.0,687.0,717.0,723.0,727.0,729.0,730.0,734.0,742.0,745.0,747.0,751.0,755.0,758.0,762.0,766.0,769.0,772.0,798.0,805.0,819.0,838.0,842.0,853.0,854.0,855.0,858.0,859.0,870.0,876.0,877.0,889.0,890.0,916.0,918.0,933.0,936.0,940.0,942.0,959.0,969.0,972.0,973.0,981.0,983.0,1013.0,1078.0,1088.0,1089.0,1090.0,1095.0,1113.0,1114.0,1120.0,1150.0,1152.0,1162.0,1163.0,1167.0,1170.0,1174.0,1182.0,1192.0,1193.0,1218.0,1219.0,1231.0,1232.0,1233.0,1243.0,1253.0,1264.0,1277.0,1280.0,1306.0,1317.0,1323.0,1340.0,1341.0,1349.0,1350.0,1352.0,1356.0,1357.0,1364.0,1366.0,1371.0,1387.0,1388.0,1427.0,1472.0,1475.0,1481.0,1486.0,1493.0,1499.0,1502.0,1505.0,1521.0,1527.0,1560.0,1570.0,1627.0,1629.0,1637.0,1645.0,1653.0,1666.0,1675.0,1679.0,1680.0,1684.0,1685.0,1701.0,1702.0,1714.0,1720.0,1722.0,1730.0,1751.0,1786.0,1807.0,1814.0,1826.0,1833.0,1834.0,1838.0,1840.0,1847.0,1853.0,1856.0,1858.0,1868.0,1897.0,1926.0,1933.0,1938.0,1959.0,1965.0,1981.0,1989.0,2011.0,2014.0,2015.0,2027.0,2034.0,2051.0,2065.0,2126.0,2128.0,2144.0,2153.0,2161.0,2170.0,2175.0,2192.0,2195.0,2205.0,2217.0,2227.0,2237.0,2239.0,2297.0,2320.0,2353.0,2388.0,2401.0,2438.0,2467.0,2471.0,2556.0,2612.0],"survival_probabilities":[1.0,1.0,1.0,1.0,1.0,0.9926430164972103,0.9853074911989619,0.9853074911989619,0.9853074911989619,0.9779500375873874,0.9706069194529199,0.9632886009984115,0.9559681013707367,0.948652325181588,0.948652325181588,0.9413399821970588,0.934043350526736,0.9267729021851571,0.9195144972852713,0.9122775093199004,0.9122775093199004,0.90503893146627,0.897832598105531,0.897832598105531,0.890622985437912,0.876312598061442,0.8691841393202729,0.8691841393202729,0.8620532795649083,0.8549494523034687,0.8478690321038924,0.8338101391970457,0.8338101391970457,0.826782099310572,0.8197818763645349,0.8128099983206598,0.8058665543942133,0.8058665543942133,0.7989200154198575,0.7989200154198575,0.7919722226966315,0.7850215315848352,0.7780995240935724,0.7780995240935724,0.7711585354027476,0.7642507004356638,0.7573782357406155,0.7505355369593404,0.7437255576996802,0.7302076015925404,0.7234775092313022,0.7167758544547578,0.7101072340637516,0.7034686070907588,0.6968580343311753,0.6902816938027281,0.683737651118634,0.683737651118634,0.6771794085184565,0.6641825768198921,0.657720908631886,0.6449234989098338,0.6449234989098338,0.6385303979398245,0.6321616673870164,0.625825631063052,0.6195214720378904,0.6132490574741314,0.6132490574741314,0.6069599703414407,0.6007047794285281,0.5883251361075904,0.5883251361075904,0.5883251361075904,0.5820828864088551,0.5758419697733265,0.5758419697733265,0.5758419697733265,0.5758419697733265,0.569482371180502,0.5631573764781461,0.5568153721504469,0.5568153721504469,0.5568153721504469,0.5504448197402043,0.5441063046039747,0.5378100956422793,0.5378100956422793,0.5315113264947503,0.5252463892209058,0.5252463892209058,0.5252463892209058,0.5189482520093037,0.5189482520093037,0.5126608415409983,0.5126608415409983,0.5063820379834619,0.5001394610664832,0.5001394610664832,0.4938939387718466,0.4876847840520047,0.4815044426888724,0.4753639327825241,0.4753639327825241,0.4753639327825241,0.4630690728508057,0.4630690728508057,0.45086545541351786,0.45086545541351786,0.444721187135447,0.444721187135447,0.4385831221919821,0.4324871385097541,0.4324871385097541,0.4324871385097541,0.4324871385097541,0.4324871385097541,0.4324871385097541,0.4324871385097541,0.42612973912166,0.42612973912166,0.42612973912166,0.42612973912166,0.41965258678101186,0.41321481752368455,0.41321481752368455,0.41321481752368455,0.41321481752368455,0.41321481752368455,0.41321481752368455,0.41321481752368455,0.41321481752368455,0.41321481752368455,0.4064302468698023,0.39970957794049966,0.39970957794049966,0.39300042698442716,0.39300042698442716,0.39300042698442716,0.38621717518978127,0.3794646172684357,0.3794646172684357,0.3727307102358693,0.3660531661506656,0.35943458470067274,0.3528822941672812,0.3528822941672812,0.3528822941672812,0.3528822941672812,0.3528822941672812,0.3460963550063948,0.3460963550063948,0.3460963550063948,0.3392478990522936,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.33246964610354746,0.3250779999343414,0.31775506749560417,0.3105212065590503,0.3033720037874019,0.3033720037874019,0.3033720037874019,0.3033720037874019,0.2960433078700375,0.2960433078700375,0.2887521656203789,0.2887521656203789,0.2887521656203789,0.2887521656203789,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.2811609927378492,0.27241445284964194,0.27241445284964194,0.2637304811337821,0.2637304811337821,0.25505380472045763,0.25505380472045763,0.25505380472045763,0.25505380472045763,0.25505380472045763,0.2458743130870462,0.2458743130870462,0.2458743130870462,0.23609625771510837,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.21707005591565862,0.20274298393550003,0.20274298393550003,0.20274298393550003,0.1880247162188207,0.1880247162188207,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696,0.17336751755340696],"lower_bound":[1.0,1.0,1.0,1.0,1.0,0.9884621402070002,0.9770064953761046,0.9770064953761046,0.9770064953761046,0.9655654702357873,0.9541956881945499,0.9429131181179515,0.9316760962590118,0.9204953557015874,0.9204953557015874,0.9093690040720889,0.898315693245407,0.8873510271868725,0.8764534591289258,0.8656368883991079,0.8656368883991079,0.8548668934318593,0.8441936705527302,0.8441936705527302,0.8335644792397324,0.8126120838786192,0.8022475831096039,0.8022475831096039,0.7919280895900508,0.7816961176105567,0.7715461014267874,0.7515356506965193,0.7515356506965193,0.7416042965792218,0.7317601031459835,0.7220034113593464,0.712333938486056,0.712333938486056,0.7027076920411837,0.7027076920411837,0.6931274449799412,0.6835911514311183,0.6741420552565411,0.6741420552565411,0.6647151722032724,0.6553813454933137,0.6461430408679764,0.6369922311061191,0.6279324004391221,0.6100887397837743,0.6012749795089664,0.5925449058916034,0.5839040532692528,0.5753480116701511,0.5668738641469195,0.5584890689895532,0.5501906548498817,0.5501906548498817,0.5419196564599535,0.5256636505339968,0.5176488122034423,0.5019079820897635,0.5019079820897635,0.49411086390075754,0.48638770930311226,0.4787482075904525,0.47119089117500884,0.4637151284504516,0.4637151284504516,0.45626324772112764,0.44889517980582455,0.43444213295101647,0.43444213295101647,0.43444213295101647,0.42721983717267553,0.4200432058361049,0.4200432058361049,0.4200432058361049,0.4200432058361049,0.41277569352936017,0.40559359095359193,0.3984383198790589,0.3984383198790589,0.3984383198790589,0.39129758682923055,0.3842394924458684,0.37727488122455927,0.37727488122455927,0.37035391685705815,0.36351647357397837,0.36351647357397837,0.36351647357397837,0.3566896251275027,0.3566896251275027,0.3499214785453696,0.3499214785453696,0.34320978073351316,0.3365837984563216,0.3365837984563216,0.33000182871327005,0.3235051763382994,0.31708545223471024,0.3107535772381215,0.3107535772381215,0.3107535772381215,0.298215821430886,0.298215821430886,0.28595786422338426,0.28595786422338426,0.2798573322879516,0.2798573322879516,0.2738108749721105,0.26785355325835647,0.26785355325835647,0.26785355325835647,0.26785355325835647,0.26785355325835647,0.26785355325835647,0.26785355325835647,0.2616916903586247,0.2616916903586247,0.2616916903586247,0.2616916903586247,0.25546757140977594,0.24933546982643356,0.24933546982643356,0.24933546982643356,0.24933546982643356,0.24933546982643356,0.24933546982643356,0.24933546982643356,0.24933546982643356,0.24933546982643356,0.24293187944399838,0.23664855703276744,0.23664855703276744,0.23043594844199314,0.23043594844199314,0.23043594844199314,0.2242160581958018,0.21808602280587341,0.21808602280587341,0.2120346996186399,0.20609541726972092,0.20026937346319004,0.19456176915460466,0.19456176915460466,0.19456176915460466,0.19456176915460466,0.19456176915460466,0.18871416326078935,0.18871416326078935,0.18871416326078935,0.18287876324851712,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.1771691038080949,0.17101817773978426,0.1650027558779045,0.15913779388278745,0.15341769408777695,0.15341769408777695,0.15341769408777695,0.15341769408777695,0.14763343324015757,0.14763343324015757,0.14195946436874454,0.14195946436874454,0.14195946436874454,0.14195946436874454,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1361384229974828,0.1295420303777383,0.1295420303777383,0.12311150724213125,0.12311150724213125,0.11680614812221128,0.11680614812221128,0.11680614812221128,0.11680614812221128,0.11680614812221128,0.11026763040554503,0.11026763040554503,0.11026763040554503,0.10345468642602361,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.0906575460734227,0.08143287325218468,0.08143287325218468,0.08143287325218468,0.07233692820662455,0.07233692820662455,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724,0.06367452774712724],"upper_bound":[1.0,1.0,1.0,1.0,1.0,0.9942853784236048,0.9885779761597383,0.9885779761597383,0.9885779761597383,0.9828439488408995,0.9771114559651015,0.971388654738584,0.9656544014180011,0.9599140182410446,0.9599140182410446,0.9541664164822562,0.9484211918574392,0.942686580811853,0.9369514134458707,0.9312230689090623,0.9312230689090623,0.9254832797986564,0.9197588405177448,0.9197588405177448,0.9140214933926797,0.9026024796340124,0.8968987515481526,0.8968987515481526,0.8911826146038538,0.885477611595789,0.8797808364703293,0.8684376047504282,0.8684376047504282,0.8627510953721217,0.8570763251930626,0.8514137397989573,0.8457634307405588,0.8457634307405588,0.8400996857710042,0.8400996857710042,0.8344238795696374,0.828734539958458,0.8230574595567877,0.8230574595567877,0.8173534468766046,0.8116652561946258,0.8059947570443914,0.8003373614326307,0.7946955411471426,0.7834619777783505,0.7778518696284686,0.7722538447563861,0.7666717706563448,0.7611031337729923,0.7555463264019177,0.7500065721148768,0.7444822833888967,0.7444822833888967,0.7389341187594927,0.727903293883587,0.722401116916885,0.7114680905487775,0.7114680905487775,0.7059882048224133,0.7005169814347573,0.695061585702547,0.6896213506221013,0.6841961954317196,0.6841961954317196,0.6787441325616471,0.6733088947033293,0.6625144643043902,0.6625144643043902,0.6625144643043902,0.657052284978093,0.651578146262073,0.651578146262073,0.651578146262073,0.651578146262073,0.6459862255215478,0.6404108475822302,0.6348063820522633,0.6348063820522633,0.6348063820522633,0.6291622817228112,0.623532032451194,0.6179248058192144,0.6179248058192144,0.6123005740393398,0.6066917296324001,0.6066917296324001,0.6066917296324001,0.6010380443272881,0.6010380443272881,0.595378644738344,0.595378644738344,0.589711463502769,0.5840613624186707,0.5840613624186707,0.5783927731364039,0.5727412611921383,0.5670999547844,0.5614789282999133,0.5614789282999133,0.5614789282999133,0.5501750125817879,0.5501750125817879,0.5388883377571826,0.5388883377571826,0.5331799060485287,0.5331799060485287,0.5274595796929857,0.5217607036304904,0.5217607036304904,0.5217607036304904,0.5217607036304904,0.5217607036304904,0.5217607036304904,0.5217607036304904,0.5157982485724496,0.5157982485724496,0.5157982485724496,0.5157982485724496,0.5097029614890923,0.5036238289620588,0.5036238289620588,0.5036238289620588,0.5036238289620588,0.5036238289620588,0.5036238289620588,0.5036238289620588,0.5036238289620588,0.5036238289620588,0.4971942176474041,0.49080143021598405,0.49080143021598405,0.4843955501765293,0.4843955501765293,0.4843955501765293,0.4778939776451353,0.47139638243310794,0.47139638243310794,0.46489090267030375,0.4584138380536823,0.4519678095013126,0.44556011413035046,0.44556011413035046,0.44556011413035046,0.44556011413035046,0.44556011413035046,0.43889577999076984,0.43889577999076984,0.43889577999076984,0.43214032040654793,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.4254239793668269,0.41806479590090595,0.41073698806071385,0.40346109496847726,0.39623297134327745,0.39623297134327745,0.39623297134327745,0.39623297134327745,0.38878367167258626,0.38878367167258626,0.38133145832975235,0.38133145832975235,0.38133145832975235,0.38133145832975235,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.37352767092997924,0.3644773854712047,0.3644773854712047,0.3554272439868712,0.3554272439868712,0.34631781485733953,0.34631781485733953,0.34631781485733953,0.34631781485733953,0.34631781485733953,0.3366045993283881,0.3366045993283881,0.3366045993283881,0.32616822930963446,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.30557769770785387,0.2898054273847799,0.2898054273847799,0.2898054273847799,0.27334013273279206,0.27334013273279206,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455,0.25665357661450455]}

Use https://curlconverter.com/ to translate the following request in your favorite programming language.

!curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-F "file=@gbsg2_2.csv;type=text/csv" \
"https://www.techtonique.net/survivalcurve?method=RidgeCV&patient_id=1"
{"times":[8.0,16.0,17.0,42.0,57.0,65.0,67.0,71.0,113.0,114.0,160.0,171.0,173.0,177.0,195.0,205.0,213.0,223.0,229.0,238.0,242.0,273.0,281.0,293.0,296.0,316.0,319.0,338.0,343.0,358.0,359.0,360.0,368.0,372.0,415.0,424.0,426.0,429.0,446.0,448.0,449.0,456.0,461.0,465.0,471.0,475.0,488.0,490.0,491.0,498.0,502.0,515.0,529.0,533.0,535.0,536.0,537.0,542.0,545.0,546.0,547.0,548.0,550.0,552.0,557.0,563.0,567.0,573.0,578.0,579.0,596.0,598.0,600.0,622.0,623.0,624.0,628.0,629.0,631.0,646.0,650.0,651.0,652.0,670.0,687.0,698.0,707.0,722.0,723.0,727.0,729.0,730.0,734.0,737.0,741.0,745.0,747.0,751.0,755.0,758.0,768.0,772.0,790.0,792.0,797.0,799.0,806.0,836.0,838.0,853.0,855.0,857.0,858.0,861.0,867.0,876.0,877.0,889.0,918.0,936.0,942.0,945.0,956.0,960.0,964.0,967.0,972.0,974.0,986.0,995.0,1062.0,1078.0,1088.0,1089.0,1093.0,1094.0,1108.0,1113.0,1114.0,1117.0,1119.0,1125.0,1140.0,1146.0,1163.0,1170.0,1171.0,1177.0,1183.0,1192.0,1218.0,1222.0,1232.0,1233.0,1246.0,1250.0,1277.0,1296.0,1317.0,1323.0,1329.0,1331.0,1337.0,1340.0,1341.0,1342.0,1350.0,1352.0,1357.0,1371.0,1387.0,1420.0,1427.0,1434.0,1443.0,1449.0,1460.0,1475.0,1481.0,1483.0,1486.0,1499.0,1502.0,1505.0,1514.0,1527.0,1528.0,1557.0,1560.0,1578.0,1582.0,1587.0,1601.0,1603.0,1627.0,1632.0,1637.0,1641.0,1645.0,1679.0,1680.0,1685.0,1701.0,1702.0,1703.0,1717.0,1722.0,1730.0,1735.0,1743.0,1751.0,1753.0,1781.0,1786.0,1806.0,1807.0,1814.0,1818.0,1820.0,1821.0,1833.0,1840.0,1847.0,1853.0,1854.0,1855.0,1858.0,1861.0,1868.0,1884.0,1926.0,1938.0,1956.0,1959.0,1965.0,1975.0,1981.0,1989.0,2009.0,2011.0,2015.0,2017.0,2057.0,2132.0,2144.0,2148.0,2161.0,2170.0,2195.0,2205.0,2217.0,2227.0,2234.0,2239.0,2271.0,2297.0,2380.0,2388.0,2456.0,2467.0,2471.0,2563.0,2612.0],"survival_probabilities":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.9850347345645151,0.9850347345645151,0.9701769984353411,0.9554476289140442,0.9408716920972592,0.926453261769638,0.9122014885142319,0.8980436368864061,0.8980436368864061,0.884011756973658,0.884011756973658,0.870102655842479,0.8563572576355334,0.8563572576355334,0.8427128226839978,0.8292200500365426,0.8292200500365426,0.8158382474730229,0.8158382474730229,0.8025623166790152,0.7894384878656601,0.7764628395207585,0.7636309605177486,0.750945343454109,0.750945343454109,0.7383632513485489,0.7259399512820207,0.7259399512820207,0.7136076789878719,0.7136076789878719,0.7013753846893394,0.689297582302662,0.677320728778909,0.6655012797407651,0.6655012797407651,0.6538035519438978,0.6422394734594478,0.6307973669944643,0.6307973669944643,0.6194612079667899,0.6082689850342342,0.5972306850462697,0.5863440410005595,0.5756032812606301,0.5756032812606301,0.5649082507840368,0.554361070675578,0.5439565888444765,0.5336923149425773,0.5235543785373307,0.5135666729728444,0.5135666729728444,0.5036545121469267,0.49387873746528227,0.48425198410213394,0.47477112949034117,0.46543105359510845,0.4562384336381525,0.4562384336381525,0.4471343785605461,0.4381741086346959,0.4293503639721473,0.4293503639721473,0.4206007362916227,0.41198641347772635,0.40348917381329613,0.40348917381329613,0.3950600161620572,0.3950600161620572,0.3950600161620572,0.3950600161620572,0.38661004426539614,0.3782972742220044,0.3782972742220044,0.3782972742220044,0.36997391123831486,0.36178816771602473,0.3537373288615585,0.3458235703681165,0.3458235703681165,0.3458235703681165,0.3379824907938,0.33027275492532576,0.322696737875122,0.322696737875122,0.322696737875122,0.322696737875122,0.31513772063667345,0.307705669504156,0.307705669504156,0.30033873948003564,0.30033873948003564,0.30033873948003564,0.292900959561292,0.2856092115688657,0.2856092115688657,0.27840587093790914,0.27133091909458995,0.27133091909458995,0.2643651493275328,0.25753294791783204,0.25753294791783204,0.25079010077879554,0.25079010077879554,0.25079010077879554,0.24405265134324355,0.2374472335322808,0.23096720963611056,0.23096720963611056,0.2245853337285025,0.21834005493692848,0.21834005493692848,0.21834005493692848,0.21834005493692848,0.21205169290156164,0.20590000822399004,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19982854989839258,0.19343958917837847,0.18721105957097586,0.18721105957097586,0.18721105957097586,0.18721105957097586,0.18721105957097586,0.18721105957097586,0.1808932870151693,0.1747326168163815,0.1747326168163815,0.16868198535221335,0.16868198535221335,0.16868198535221335,0.16267055469515063,0.16267055469515063,0.15676924338435497,0.15676924338435497,0.15676924338435497,0.15676924338435497,0.15089391122490098,0.15089391122490098,0.15089391122490098,0.15089391122490098,0.15089391122490098,0.15089391122490098,0.14492653390259747,0.14492653390259747,0.1390441872259377,0.1390441872259377,0.1390441872259377,0.1390441872259377,0.1390441872259377,0.13314381111074639,0.13314381111074639,0.12737581008575588,0.12179986958892614,0.11641627644782113,0.11641627644782113,0.11641627644782113,0.11641627644782113,0.1110593970134741,0.10588072504036736,0.10588072504036736,0.10083820675188139,0.10083820675188139,0.10083820675188139,0.10083820675188139,0.10083820675188139,0.10083820675188139,0.10083820675188139,0.10083820675188139,0.09550195634109669,0.09550195634109669,0.09550195634109669,0.09550195634109669,0.09550195634109669,0.09011605647174771,0.0849586753683147,0.0849586753683147,0.0849586753683147,0.0849586753683147,0.0849586753683147,0.07978784249104752,0.07978784249104752,0.07480662651173428,0.07480662651173428,0.07480662651173428,0.06992741250203358,0.06992741250203358,0.06992741250203358,0.06992741250203358,0.06992741250203358,0.06992741250203358,0.06992741250203358,0.06992741250203358,0.06992741250203358,0.06436143002588054,0.06436143002588054,0.06436143002588054,0.05899550603678293,0.05899550603678293,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.05389718523070206,0.04631955648989847,0.04631955648989847,0.0392866722911965,0.0392866722911965,0.0392866722911965,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.03247270620156236,0.01387537916285396,0.01387537916285396,0.01387537916285396,0.01387537916285396,0.01387537916285396],"lower_bound":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.9777936922345029,0.9777936922345029,0.9559096478455176,0.9343759453355079,0.9132258639114125,0.8924614729547972,0.8720918966429987,0.8520101617173641,0.8520101617173641,0.8322593751262322,0.8322593751262322,0.8128322194703534,0.7937824183969492,0.7937824183969492,0.7750199401985987,0.7566116156394026,0.7566116156394026,0.738498881063076,0.738498881063076,0.7206725289551156,0.7031916633078089,0.6860474077515849,0.6692304183404885,0.652740479696959,0.652740479696959,0.636519202122646,0.6206348016101011,0.6206348016101011,0.6049977991199036,0.6049977991199036,0.5896176444765305,0.5745599692327344,0.5597550945812683,0.5452698353355234,0.5452698353355234,0.5310571610075008,0.51712864261571,0.5034672907691136,0.5034672907691136,0.49005148549230565,0.4769233512202695,0.4640910175704126,0.45154814935890225,0.43928452863307077,0.43928452863307077,0.4271838800607741,0.41535979346501234,0.4038030365371562,0.39250750980975885,0.3814548719269769,0.37066794424501276,0.37066794424501276,0.36006361651858954,0.34970474186380474,0.3396013532095546,0.32974667957248205,0.320132037126187,0.310760921202517,0.310760921202517,0.3015707052156138,0.2926145959760763,0.283882090904699,0.283882090904699,0.275309217036164,0.26695373381733767,0.2587951423534684,0.2587951423534684,0.2507845606744139,0.2507845606744139,0.2507845606744139,0.2507845606744139,0.2428377109155859,0.23510238412642046,0.23510238412642046,0.23510238412642046,0.22744009223833214,0.21998630745618702,0.21273541490943704,0.20568624572387778,0.20568624572387778,0.20568624572387778,0.19877923285011903,0.1920639354189171,0.1855394056202775,0.1855394056202775,0.1855394056202775,0.1855394056202775,0.17910379459142117,0.1728494929375391,0.1728494929375391,0.16672251496071663,0.16672251496071663,0.16672251496071663,0.16061077799428314,0.15469230151532318,0.15469230151532318,0.14891773129544156,0.14331680199313301,0.14331680199313301,0.13787168208129216,0.13259873307568013,0.13259873307568013,0.1274614276379616,0.1274614276379616,0.1274614276379616,0.12239530442191464,0.11749445117186758,0.1127510183679845,0.1127510183679845,0.10814264553131227,0.10369451603043062,0.10369451603043062,0.10369451603043062,0.10369451603043062,0.09927817458312477,0.09501938493132038,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.09087674321139975,0.08658350412539813,0.0824643273779839,0.0824643273779839,0.0824643273779839,0.0824643273779839,0.0824643273779839,0.0824643273779839,0.07835409872087289,0.07441314819224346,0.07441314819224346,0.07060820451218246,0.07060820451218246,0.07060820451218246,0.06689348013494775,0.06689348013494775,0.06331155761745372,0.06331155761745372,0.06331155761745372,0.06331155761745372,0.05981035644410121,0.05981035644410121,0.05981035644410121,0.05981035644410121,0.05981035644410121,0.05981035644410121,0.05632196085451257,0.05632196085451257,0.05295138047478372,0.05295138047478372,0.05295138047478372,0.05295138047478372,0.05295138047478372,0.049639861648580995,0.049639861648580995,0.04647130567741314,0.043474262317194125,0.04064359862260499,0.04064359862260499,0.04064359862260499,0.04064359862260499,0.03788985870566009,0.03528879184579356,0.03528879184579356,0.03281522245289069,0.03281522245289069,0.03281522245289069,0.03281522245289069,0.03281522245289069,0.03281522245289069,0.03281522245289069,0.03281522245289069,0.03026273562937129,0.03026273562937129,0.03026273562937129,0.03026273562937129,0.03026273562937129,0.027756340217606725,0.025423994696945326,0.025423994696945326,0.025423994696945326,0.025423994696945326,0.025423994696945326,0.023154127947703256,0.023154127947703256,0.021034507825481382,0.021034507825481382,0.021034507825481382,0.019024190070463062,0.019024190070463062,0.019024190070463062,0.019024190070463062,0.019024190070463062,0.019024190070463062,0.019024190070463062,0.019024190070463062,0.019024190070463062,0.01681349884454415,0.01681349884454415,0.01681349884454415,0.014769017543064736,0.014769017543064736,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.012908964786493933,0.010301284973675846,0.010301284973675846,0.008060764726131832,0.008060764726131832,0.008060764726131832,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.00606972935549959,0.0017108084970612024,0.0017108084970612024,0.0017108084970612024,0.0017108084970612024,0.0017108084970612024],"upper_bound":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.9890357861894913,0.9890357861894913,0.9781059626957258,0.9672260612772353,0.9564150135262153,0.9456763993224725,0.9350176641044533,0.9243847516528279,0.9243847516528279,0.9138018880648741,0.9138018880648741,0.903266961241527,0.8928114530361202,0.8928114530361202,0.8823880261183481,0.8720357460408529,0.8720357460408529,0.8617237817619421,0.8617237817619421,0.8514483695195811,0.8412456705341316,0.8311132420713905,0.821048213719587,0.8110531160870793,0.8110531160870793,0.8010946471255131,0.7912169969883639,0.7912169969883639,0.7813666726977062,0.7813666726977062,0.7715508914145164,0.7618138232550081,0.7521127397567783,0.7424938345250077,0.7424938345250077,0.7329286619021126,0.7234274432646243,0.7139810630453176,0.7139810630453176,0.7045766134913842,0.6952460730690552,0.6859985356399908,0.6768329345746245,0.6677452106837617,0.6677452106837617,0.6586507652421143,0.6496365972547786,0.6406990983093293,0.6318368914425202,0.6230386709824397,0.6143259266145377,0.6143259266145377,0.6056339282366047,0.5970163667352655,0.5884852403649898,0.5800387288497778,0.5716731805158768,0.5633955182715733,0.5633955182715733,0.5551532945109763,0.5469970737334958,0.5389211899433652,0.5389211899433652,0.5308689608258047,0.5228971381442377,0.5149896426077563,0.5149896426077563,0.5071011460474352,0.5071011460474352,0.5071011460474352,0.5071011460474352,0.4991476187407067,0.4912774995411907,0.4912774995411907,0.4912774995411907,0.4833506275256546,0.4755079209862791,0.4677477953632988,0.46007338661093405,0.46007338661093405,0.46007338661093405,0.45242275016643657,0.44485360091937676,0.4373693176948229,0.4373693176948229,0.4373693176948229,0.4373693176948229,0.4298545973644599,0.42241870554321165,0.42241870554321165,0.4150001622870974,0.4150001622870974,0.4150001622870974,0.40746047064743546,0.4000186803185738,0.4000186803185738,0.392616792734436,0.3852965443246637,0.3852965443246637,0.3780389570587493,0.370870420266885,0.370870420266885,0.3637453301894268,0.3637453301894268,0.3637453301894268,0.35657431224537406,0.349491968312398,0.34249241582914336,0.34249241582914336,0.3355470863160291,0.32869885663938625,0.32869885663938625,0.32869885663938625,0.32869885663938625,0.32174995973187664,0.31489828296645417,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3080817830250039,0.3008483994599454,0.2937345575166543,0.2937345575166543,0.2937345575166543,0.2937345575166543,0.2937345575166543,0.2937345575166543,0.2864534674048308,0.2792872987700364,0.2792872987700364,0.2721827007898161,0.2721827007898161,0.2721827007898161,0.26505594759928064,0.26505594759928064,0.2579905348010573,0.2579905348010573,0.2579905348010573,0.2579905348010573,0.25088482145228996,0.25088482145228996,0.25088482145228996,0.25088482145228996,0.25088482145228996,0.25088482145228996,0.24359120818220004,0.24359120818220004,0.23632206072034195,0.23632206072034195,0.23632206072034195,0.23632206072034195,0.23632206072034195,0.22894707156830552,0.22894707156830552,0.2216521088690773,0.21451513632296515,0.20754052612838803,0.20754052612838803,0.20754052612838803,0.20754052612838803,0.2005138954718162,0.19363385909154204,0.19363385909154204,0.18684721397513887,0.18684721397513887,0.18684721397513887,0.18684721397513887,0.18684721397513887,0.18684721397513887,0.18684721397513887,0.18684721397513887,0.17956503132649235,0.17956503132649235,0.17956503132649235,0.17956503132649235,0.17956503132649235,0.1721032444117409,0.1648448265510982,0.1648448265510982,0.1648448265510982,0.1648448265510982,0.1648448265510982,0.15744749035413388,0.15744749035413388,0.15019850189340492,0.15019850189340492,0.15019850189340492,0.14297098194977492,0.14297098194977492,0.14297098194977492,0.14297098194977492,0.14297098194977492,0.14297098194977492,0.14297098194977492,0.14297098194977492,0.14297098194977492,0.13455817204335338,0.13455817204335338,0.13455817204335338,0.12626039502267997,0.12626039502267997,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.11818622986275625,0.10579254261815278,0.10579254261815278,0.09379136014307927,0.09379136014307927,0.09379136014307927,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.08159734173941835,0.043820412179131504,0.043820412179131504,0.043820412179131504,0.043820412179131504,0.043820412179131504]}

2 - Using Python

Obtain survival curves for the 4 first patients in the test set (patients with training_index=0)

import requests

headers = {
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
}

responses = []

for patient_id in range(4):

  params = {
      'method': 'RidgeCV',
      'patient_id': str(patient_id),
  }

  files = {
      'file': ('gbsg2_2.csv', open('gbsg2_2.csv', 'rb'), 'text/csv'),
  }

  responses.append(requests.post('https://www.techtonique.net/survivalcurve',
                                 params=params, headers=headers, files=files).json())

Plot survival curves for the 4 first patients in the test set (patients with training_index=0) including prediction intervals

import matplotlib.pyplot as plt
fig, axes = plt.subplots(2, 2, figsize=(10, 8))

for i, response in enumerate(responses):
  row = i // 2
  col = i % 2
  axes[row, col].plot(response["times"], response["survival_probabilities"], label=f'Patient {i}')
  axes[row, col].fill_between(response["times"],
                              response["lower_bound"],
                              response["upper_bound"],
                              color='gray', alpha=0.3, label='Confidence Interval')
  axes[row, col].set_xlabel('Time')
  axes[row, col].set_ylabel('Survival Probability')
  axes[row, col].set_title(f'Survival Curve for Patient {i}')
  axes[row, col].legend()
  axes[row, col].grid(True)

plt.tight_layout()
plt.show()

image-title-here

Compare survival curves for the 4 first patients in the test set (patients with training_index=0)

import matplotlib.pyplot as plt

for i, response in enumerate(responses):
  plt.plot(response["times"], response["survival_probabilities"],
           label=f'Patient {i}')

plt.xlabel('Time')
plt.ylabel('Survival Probability')
plt.title('Survival Curves for 4 Patients')
plt.legend()
plt.grid(True)
plt.show()

image-title-here

Kaplan-Meier survival curve for the entire population

import requests

headers = {
    'Authorization': 'Bearer YOUR_TOKEN_HERE',
}

params = {
    'method': 'km',
}

files = {
    'file': ('kidney.csv', open('kidney.csv', 'rb'), 'text/csv'),
}

response = requests.post('https://www.techtonique.net/survivalcurve', params=params, headers=headers, files=files)
import json
import matplotlib.pyplot as plt

# Assuming the response object 'response' contains the survival curve data as JSON
data = response.json()

# Extract time and survival probability data
time = data['times']
survival = data['survival_probabilities']

# Plot the survival curve
plt.figure(figsize=(10, 6))
plt.step(time, survival, where='post')
plt.xlabel('Time')
plt.ylabel('Survival Probability')
plt.title('Kaplan-Meier Survival Curve')
plt.grid(True)
plt.show()

image-title-here

Comments powered by Talkyard.