# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
from collections import Counter
import json

import pandas as pd

# +
with open("../data/idx2rep.json", 'r') as fin:
    idx2rep = json.load(fin)

with open("../data/list/friends_train.list", 'r') as fin:
    train_list = fin.readlines()
with open("../data/list/friends_test.list", 'r') as fin:
    test_list = fin.readlines()
# -

train_labels = []
for l in train_list:
    _, _, _, labels, _ = l.split('\t')
    labels = labels.strip()
    labels = labels.split(',')
    train_labels += labels
test_labels = []
for l in test_list:
    _, _, _, labels, _ = l.split('\t')
    labels = labels.strip()
    labels = labels.split(',')
    test_labels += labels

train_counter = Counter(train_labels)
test_counter = Counter(test_labels)

table = []
for action_label in train_counter.keys():
    rep = idx2rep[action_label]
    n_train = train_counter[action_label]
    n_test = test_counter[action_label]
    train_ratio = n_train / (n_train + n_test)
    table.append([ rep, n_train, n_test, train_ratio ])
pd.DataFrame(table, columns=[ 'action', '#label in train', '#label in test', 'ratio' ])



StarcoderdataJupyterScriptsDedupFiltered