कोवेरिएट्स के साथ Weibull मॉडल

Python में Survival Analysis

Shae Wang

Senior Data Scientist

Survival functions की तुलना

Kaplan-Meier एस्टीमेटर से समूह तुलना करें:

अपार्टमेंट बनाम हाउस के Kaplan-Meier सरवाइवल कर्व्स.

Log-rank टेस्ट से समूह तुलना करें:

<lifelines.StatisticalResult: logrank_test>
 null_distribution = chi squared
degrees_of_freedom = 1
         test_name = logrank_test
 test_statistic    p  -log2(p)
           0.09 0.77      0.38

   

Q: एक या अधिक continuous वैरिएबल्स सरवाइवल फंक्शन को कैसे/कितना प्रभावित करते हैं, यह हम कैसे जाँचें?

Python में Survival Analysis

Survival regression

  • एक मेथड जो कोवेरिएट्स के साथ सरवाइवल फंक्शंस को मॉडल करता है
  • हर कोवेरिएट का सरवाइवल फंक्शन पर असर मापता है

$$Y_i=f(X_i,\beta)$$

$$Y_i: \text{durations}, X_i: \text{covariates}$$

  • उदाहरण कोवेरिएट्स: age, weight, country
Python में Survival Analysis

Accelerated Failure Time (AFT) मॉडल

$$\text{Population A}: S_A(t)$$

$$\text{Population B}: S_B(t)$$

$$S_A(t)=S_B(t*\lambda)$$

  • $S_B(t)$, $S_A(t)$ के साथ फैक्टर $\lambda$ से तेज़ (accelerate) या धीमा (decelerate) होता है.

  • AFT मॉडल यह acceleration/deceleration संबंध कोवेरिएट्स के आधार पर कैप्चर करता है.

  • जब कोई कोवेरिएट $a$ से $b$ होता है, time-to-event accelerated failure rate $\lambda$ से तेज़ या धीमा हो जाता है.
  • उदाहरण: $S_{dog}(t)=S_{human}(t*7)$
Python में Survival Analysis

Survival regression के लिए डेटा

DataFrame उदाहरण: mortgage_df

id property_type principal interest property_tax credit_score duration paid_off
1 house 1275 0.035 0.019 780 25 0
2 apartment 756 0.028 0.020 695 17 1
3 apartment 968 0.029 0.017 810 5 0
... ... ... ... ... ... ... ...
1000 house 1505 0.041 0.023 750 30 1
Python में Survival Analysis

Weibull और AFT का संयोजन: Weibull AFT मॉडल

  • DataFrame: mortgage_df
  • कोवेरिएट्स:
    • property_type को एक dummy वैरिएबल से replaced किया गया:
      • house: 1 अगर "house", 0 अगर "apartment"
    • principal
    • interest
    • property_tax
    • credit_score
  1. WeibullAFTFitter क्लास इम्पोर्ट करें और instantiate करें
    from lifelines import WeibullAFTFitter
    aft = WeibullAFTFitter()
    
  2. .fit() कॉल करके estimator को डेटा पर फिट करें
    aft.fit(df=mortgage_df,
         duration_col="duration",
         event_col="paid_off")
    
Python में Survival Analysis

मॉडल आउटपुट की व्याख्या

print(aft.summary)
<lifelines.WeibullAFTFitter: fitted with 1808 observations, 340 censored>
                      coef  exp(coef)  se(coef)      z       p
lambda_ house         0.04       1.04      0.01   0.99    0.32  
        principal    -0.03       0.97      0.22  -1.04    0.30  
        interest      0.11       1.11      0.15   1.96    0.05  
        property_tax  0.31       1.36      0.27   1.15    0.25  
        credit_score -0.16       0.85      0.14  -2.33    0.02  
        Intercept     3.99      54.06      0.41   9.52 <0.0005   
rho_    Intercept     0.34       1.40      0.08   3.80 <0.0005
Python में Survival Analysis

कस्टम formula के साथ WeibullAFTFitter

कस्टम मॉडल कोवेरिएट्स के लिए formula का उपयोग:

aft.fit(df=mortgage_df,
        duration_col="duration",
        event_col="paid_off",
        formula="principal + interest * house")

इंटरैक्शन टर्म वाले linear मॉडल के समान:

$\beta_1$principal$+\beta_2$interest$+\beta_3$house$+\beta_4$interest$\cdot$house

Python में Survival Analysis

मॉडल आउटपुट की व्याख्या

print(aft.summary)
<lifelines.WeibullAFTFitter: fitted with 1808 observations, 340 censored>
                       coef  exp(coef)  se(coef)      z       p
lambda_ principal     -0.03       0.97      0.22  -1.04    0.30     
        interest       0.11       1.11      0.15   1.96    0.05  
        house          0.04       1.04      0.01   0.99    0.32  
        interest:house 0.06       1.06      0.14   0.42    0.64
        Intercept      3.99      54.06      0.41   9.52 <0.0005   
rho_    Intercept      0.34       1.40      0.08   3.80 <0.0005
Python में Survival Analysis

अभ्यास करते हैं!

Python में Survival Analysis

Preparing Video For Download...