Rehabilitation AI Partner: Code Snippets

Illustrative snippet for policy selection conditioned on adherence risk.

def select_intervention(state, policy, threshold=0.65):
    risk_score = policy.predict_risk(state)
    if risk_score > threshold:
        return "high_support_prompt"
    return "light_reminder"

def update_episode(agent, transition):
    agent.buffer.append(transition)
    if len(agent.buffer) >= agent.batch_size:
        loss = agent.learn()
        return {"loss": round(loss, 4)}
    return {"loss": None}
Back to Description All Projects