def make_dataset(features, pain_index):
    """Construct the X and y data matrices.
        
        features is a dict with key = pain name,
        value = all feature vectors for that pain source.
        
        pain_index is a dict with key = pain name, value = intensity

        In addition to X and y, we return a vector painsources which
        records the pain name for each example.
    """
    X, y, painsources = [], [], []

    for pain in features:
        for f in features[pain]:
            X.append(f)
            y.append(pain_index[pain])
            painsources.append(pain)
    return X, y, painsources