src/rime/dataset/__init__.py
def prepare_synthetic_data(split_fn_name, exclude_train=False,
                           num_users=300, num_items=200, num_events=10000):
    """ prepare synthetic data for end-to-end unit tests """
    event_df = pd.DataFrame({
        'USER_ID': np.random.choice(num_users, num_events),
        'ITEM_ID': np.random.choice(num_items, num_events),
        'TIMESTAMP': np.random.uniform(0, 5, num_events),
    }).sort_values(["USER_ID", "TIMESTAMP"])

    user_df, item_df = extract_user_item(event_df)

    if split_fn_name == 'split_by_time':
        user_df, valid_df = split_by_time(user_df, 4, 3)
    elif split_fn_name == 'split_by_user':
        user_df, valid_df = split_by_user(user_df, user_df.index % 2, 3)
    else:
        raise ValueError(f"unknown {split_fn_name}")

    D = create_dataset(event_df, user_df, item_df, 1, exclude_train=exclude_train)
    D._is_synthetic_data = True  # for hawkes_poisson verification purposes
    D.print_stats()
    V = create_dataset(event_df, valid_df, item_df, 1, exclude_train=exclude_train)
    return (D, V)
 prepare synthetic data for end-to-end unit tests 
prepare synthetic data for end-to-end unit tests
prepare synthetic data for end - to - end unit tests
def prepare_synthetic_data(split_fn_name, exclude_train=False,
                           num_users=300, num_items=200, num_events=10000):
    event_df = pd.DataFrame({
        'USER_ID': np.random.choice(num_users, num_events),
        'ITEM_ID': np.random.choice(num_items, num_events),
        'TIMESTAMP': np.random.uniform(0, 5, num_events),
    }).sort_values(["USER_ID", "TIMESTAMP"])
    user_df, item_df = extract_user_item(event_df)
    if split_fn_name == 'split_by_time':
        user_df, valid_df = split_by_time(user_df, 4, 3)
    elif split_fn_name == 'split_by_user':
        user_df, valid_df = split_by_user(user_df, user_df.index % 2, 3)
    else:
        raise ValueError(f"unknown {split_fn_name}")
    D = create_dataset(event_df, user_df, item_df, 1, exclude_train=exclude_train)
    D._is_synthetic_data = True  
    D.print_stats()
    V = create_dataset(event_df, valid_df, item_df, 1, exclude_train=exclude_train)
    return (D, V)
def prepare_synthetic_data ( split_fn_name , exclude_train = False , num_users = 300 , num_items = 200 , num_events = 10000 ) : event_df = pd . DataFrame ( { 'USER_ID' : np . random . choice ( num_users , num_events ) , 'ITEM_ID' : np . random . choice ( num_items , num_events ) , 'TIMESTAMP' : np . random . uniform ( 0 , 5 , num_events ) , } ) . sort_values ( [ "USER_ID" , "TIMESTAMP" ] ) user_df , item_df = extract_user_item ( event_df ) if split_fn_name == 'split_by_time' : user_df , valid_df = split_by_time ( user_df , 4 , 3 ) elif split_fn_name == 'split_by_user' : user_df , valid_df = split_by_user ( user_df , user_df . index % 2 , 3 ) else : raise ValueError ( f"unknown {split_fn_name}" ) D = create_dataset ( event_df , user_df , item_df , 1 , exclude_train = exclude_train ) D . _is_synthetic_data = True D . print_stats ( ) V = create_dataset ( event_df , valid_df , item_df , 1 , exclude_train = exclude_train ) return ( D , V )
prepare synthetic data for end-to-end unit tests
prepare synthetic data for end - to - end unit tests
""" prepare synthetic data for end-to-end unit tests """ # for hawkes_poisson verification purposes
split_fn_name
exclude_train
num_users
num_items
num_events