<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;Load saved models for both people2&nbsp;&nbsp;Load Spark Dataframe3&nbsp;&nbsp;Plot Total Screen Time for Multiple People by Show3.1&nbsp;&nbsp;Plot Difference in Screen Time Between Pairs of People By Show4&nbsp;&nbsp;Compare Screen Time Over Time For Multiple People on a Single Show5&nbsp;&nbsp;Co-occurence on Screen<jupyter_code>from esper.stdlib import *
from esper.prelude import *
from esper.identity import *
from esper.spark_identity import *
from esper.spark_util import *
from esper.validation import *
people = ['<NAME>', '<NAME>', '<NAME>']<jupyter_output><empty_output><jupyter_text>Load saved models for both people<jupyter_code>def load_model(name):
    print('Loading model for {}.'.format(name))
    model = FaceIdentityModel.load_from_gcs(name=name)
    imshow(tile_imgs([
        cv2.resize(x[1][0], (200, 200)) for x in model.model_params['images']], cols=10
    ))
    plt.show()
    plot_precision_and_cdf(model)
    return model

face_models = [load_model(x) for x in people]<jupyter_output><empty_output><jupyter_text>Load Spark Dataframe<jupyter_code>face_identities = get_face_identities()
print('Schema:', face_identities)<jupyter_output><empty_output><jupyter_text>Plot Total Screen Time for Multiple People by Show<jupyter_code>date_range = ['2016-01-01', '2016-11-09']
screen_time_by_canonical_show = [
    get_screen_time_by_canonical_show_spark(
        name.lower(), 
        face_identities.where(face_identities.in_commercial == False),
        date_range=date_range
    ) for name in people
]
plot_screen_time_by_show(people, screen_time_by_canonical_show)<jupyter_output><empty_output><jupyter_text>Plot Difference in Screen Time Between Pairs of People By Show<jupyter_code>from itertools import combinations

for i, j in combinations(range(len(people)), 2):
    plot_difference_in_screen_time_by_show(
        [x.lower() for x in [people[i], people[j]]], 
        [screen_time_by_canonical_show[i], screen_time_by_canonical_show[j]], 
        plot_proportion=False
    )<jupyter_output><empty_output><jupyter_text>Compare Screen Time Over Time For Multiple People on a Single Show<jupyter_code>canonical_show_name = 'MSNBC Live'
face_identities_filtered = face_identities.where(
    face_identities.canonical_show_id == CanonicalShow.objects.get(name=canonical_show_name).id
)
screen_times_by_video = [
    {
        vid : st for vid, (st, var) in get_screen_time_by_video_spark(
            name.lower(), 
            face_identities_filtered, 
            date_range=date_range
        ).items()
    } for name in people
]
plot_screentime_over_time(people, canonical_show_name, 
                          screen_times_by_video)<jupyter_output><empty_output><jupyter_text>Co-occurence on Screen<jupyter_code>get_person_in_shot_similarity_spark(
    [x.lower() for x in people], 
    face_identities, 
    date_range=date_range
)<jupyter_output><empty_output>