πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
Search courses…
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Predicting Treatment Response and Personalized Therapy

Healthcare AIPredicting Treatment Response and Personalized Therapy🟒 Free Lesson

Advertisement

Predicting Treatment Response and Personalized Therapy

Module: Healthcare AI | Difficulty: Advanced

Individual Treatment Effect (ITE)

Conditional Average Treatment Effect (CATE)

Inverse Propensity Weighting

Uplift Model Metrics

| Metric | Formula | Range | |--------|---------|-------| | Qini | Incremental Lift / Random | 0-1 | | AUUC | Area Under Uplift Curve | 0-infinity | | CATE Error | | 0-infinity |

import torch
import torch.nn as nn
import numpy as np

class TreatmentResponseNet(nn.Module):
    def __init__(self, input_dim=100, hidden_dim=64):
        super().__init__()
        self.feature_net = nn.Sequential(
            nn.Linear(input_dim, hidden_dim), nn.ReLU(),
            nn.Dropout(0.3), nn.Linear(hidden_dim, hidden_dim), nn.ReLU())
        self.treatment_net = nn.Sequential(
            nn.Linear(hidden_dim + 1, hidden_dim // 2), nn.ReLU(),
            nn.Linear(hidden_dim // 2, 1))
        self.propensity_net = nn.Linear(hidden_dim, 1)

    def forward(self, x, treatment):
        features = self.feature_net(x)
        treatment_input = torch.cat([features, treatment.unsqueeze(-1)], dim=-1)
        outcome = self.treatment_net(treatment_input)
        propensity = torch.sigmoid(self.propensity_net(features))
        return outcome, propensity

def doubly_robust_loss(outcomes_pred, outcomes_true, treatment, propensity):
    dr1 = (outcomes_pred[treatment == 1] +
           treatment[treatment == 1] *
           (outcomes_true[treatment == 1] - outcomes_pred[treatment == 1]) /
           (propensity[treatment == 1] + 1e-6)).mean()
    dr0 = (outcomes_pred[treatment == 0] +
           (1 - treatment[treatment == 0]) *
           (outcomes_true[treatment == 0] - outcomes_pred[treatment == 0]) /
           (1 - propensity[treatment == 0] + 1e-6)).mean()
    return -(dr1 - dr0)

model = TreatmentResponseNet(input_dim=100)
x = torch.randn(500, 100)
treatment = torch.randint(0, 2, (500,)).float()
outcomes_pred, propensity = model(x, treatment)
print(f'Outcomes shape: {outcomes_pred.shape}')
print(f'Propensity shape: {propensity.shape}')

Research Insight: Causal inference methods for treatment effect estimation face a fundamental challenge: we can never observe both potential outcomes for the same patient. Deep instrumental variable methods and doubly robust estimators can handle unmeasured confounding, but require strong assumptions. Targeted learning approaches achieve the best finite-sample performance.

Need Expert Healthcare AI Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement