Learn practical skills, build real-world projects, and advance your career

Course 2 week 1 lecture notebook Exercise 04

Concordance index

In this week's graded assignment, you will implement the concordance index (c-index). To get some practice with what you've seen in lecture, and to prepare for this week's assignment, you will write code to find permissible pairs, concordant pairs, and risk ties.

First start by importing packages and generating a small dataset. The data is small enough that you can visually check the pairs of patients.

# import packages
import pandas as pd

Define the outcome y

  • You will let y refer to the actual health outcome of the patient.
  • 1 indicates disease, 0 indicates health (normal)
# define 'y', the outcome of the patient
y = pd.Series([0,0,1,0])
y.name="health"
y
0    0
1    0
2    1
3    0
Name: health, dtype: int64