Exemplo n.º 1
0
def load(dev_path, act_path, retain_corrections, subject):
    """
    """
    assert subject in ['OrdonezA', 'OrdonezB']
    df_act = _load_activities(act_path)
    df_dev, df_loc = _load_devices(dev_path)

    if subject == 'OrdonezB':
        # the activity grooming is often overlapped by sleeping
        # as I deem this activity as important i make it dominant
        df_act, cor_lst = correct_activities(df_act, excepts=['Grooming'])
    elif subject == 'OrdonezA':
        df_act, cor_lst = correct_activities(df_act)

    lst_act = df_act[ACTIVITY].unique()
    lst_dev = df_dev[DEVICE].unique()

    df_dev = correct_devices(df_dev)
    data = Data(df_act, df_dev, activity_list=lst_act, device_list=lst_dev)
    data.df_dev_rooms = df_loc

    if retain_corrections:
        data.correction_activities = cor_lst

    return data
Exemplo n.º 2
0
def load(data_path):
    df = _load_df(data_path)
    df_dev = _get_devices_df(df)
    df_act = _get_activity_df(df)

    dev_rep1, dev_rep3 = correct_devices(df_dev)
    df_act, cor_lst = correct_activities(df_act)

    data = Data(df_act, dev_rep1)
    data.df_dev_rep3 = dev_rep3
    return data
Exemplo n.º 3
0
def load(data_path):
    df = _load_df(data_path)
    df_dev = _get_devices_df(df)
    df_act = _get_activity_df(df)

    df_dev = correct_devices(df_dev)
    df_act, cor_lst = correct_activities(df_act)

    lst_act = df_act[ACTIVITY].unique()
    lst_dev = df_dev[DEVICE].unique()

    data = Data(df_act, df_dev, activity_list=lst_act, device_list=lst_dev)
    return data
Exemplo n.º 4
0
def load(device_fp, activity_fp):
    df_act = _load_activities(activity_fp)
    df_dev = _load_devices(device_fp)
    df_act, cor_lst = correct_activities(df_act)

    df_dev = correct_devices(df_dev)
    lst_act = df_act[ACTIVITY].unique()
    lst_dev = df_dev[DEVICE].unique()

    data = Data(df_act, df_dev, activity_list=lst_act, device_list=lst_dev)
    data.correction_activities = cor_lst

    return data
Exemplo n.º 5
0
def load(dev_path, act_path, subject):
    """
    """
    assert subject in ['OrdonezA', 'OrdonezB']
    df_act = _load_activities(act_path)
    df_dev, df_loc = _load_devices(dev_path)

    if subject == 'OrdonezB':
        # the activity grooming is often overlapped by sleeping
        # as I deem this activity as important i make it dominant

        df_act, cor_lst = correct_activities(df_act, excepts=['Grooming'])
    elif subject == 'OrdonezA':
        df_act, cor_lst = correct_activities(df_act)
    df_dev, df_dev_rep3 = correct_devices(df_dev)

    data = Data(df_act, df_dev)
    data.df_dev_rep3 = df_dev_rep3
    data.correction_activities = cor_lst
    data.df_dev_rooms = df_loc

    return data
Exemplo n.º 6
0
def load(dev_path, act_path, data_path):
    df_dev_map = _load_device_map(dev_path)
    df_act_map = _load_activity_map(act_path)
    df_dev, df_act = _read_data(data_path, df_dev_map, df_act_map)    

    df_act, cor_lst = correct_activities(df_act)
    df_dev_rep1, df_dev_rep3 = correct_devices(df_dev)
        
    data = Data(df_act, df_dev_rep1)
    data.df_dev_rep3 = df_dev_rep3
    
    data.df_dev_map = df_dev_map
    data.df_act_map = df_act_map        
    return data
Exemplo n.º 7
0
def load(dev_path, act_path, data_path):
    df_dev_map = _load_device_map(dev_path)
    df_act_map = _load_activity_map(act_path)
    df_dev, df_act = _read_data(data_path, df_dev_map, df_act_map)

    df_act, cor_lst = correct_activities(df_act)
    df_dev = correct_devices(df_dev)

    lst_act = df_act[ACTIVITY].unique()
    lst_dev = df_dev[DEVICE].unique()

    data = Data(df_act, df_dev, activity_list=lst_act, device_list=lst_dev)
    
    data.df_dev_map = df_dev_map
    data.df_act_map = df_act_map        
    return data
Exemplo n.º 8
0
    def load_amsterdam(folder_path):
        device_fp = os.path.join(folder_path, "kasterenSenseData.txt")
        activity_fp = os.path.join(folder_path, "kasterenActData.txt")

        df_act = _load_activities(activity_fp)
        df_dev = _load_devices(device_fp)
        df_act, cor_lst = correct_activities(df_act)

        df_dev = correct_devices(df_dev)
        lst_act = df_act[ACTIVITY].unique()
        lst_dev = df_dev[DEVICE].unique()

        data = Data(df_act, df_dev, activity_list=lst_act, device_list=lst_dev)
        if retain_corrections:
            data.correction_activities = cor_lst
        return data
Exemplo n.º 9
0
def load(folder_path, subjects):
    """
    Loads a dataset generated by activity-assistant from a specified folder.

    Parameters
    ----------
    folder_path : str
        The path to the folder where the dataset is located.

    subjects : list of str
        The subjecst names that are to be included. If the activity file
        is named *activities_subject_foo.csv*, then *foo* is the corresponding name.

    Examples
    --------
    The dataset ``my_dataset.zip`` is extracted in the folder ``/path/to/``.

    >>> from pyadlml.dataset import load_act_assist
    >>> data = load_act_assist('/path/to/my_dataset/', subjects=['chris'])

    Returns
    -------
    data : object
    """
    assert isinstance(folder_path, str)
    assert isinstance(subjects, list)

    df_dev = _read_devices(os.path.join(folder_path, DATA_NAME),
                           os.path.join(folder_path, DEV_MAP_NAME))
    df_dev = correct_devices(df_dev)

    # get mappings
    lst_dev = _read_device_list(os.path.join(folder_path, DEV_MAP_NAME))
    lst_act = _read_activity_list(os.path.join(folder_path, ACT_MAP_NAME))

    data = Data(None, df_dev, activity_list=lst_act, device_list=lst_dev)

    for subject in subjects:
        df_act = _read_activities(
            os.path.join(folder_path, ACT_NAME % (subject)))
        # correct possible overlaps in activities
        df_act, cor_lst = correct_activities(df_act)
        setattr(data, 'df_activities_{}'.format(subject), df_act)
        setattr(data, 'correction_activities_{}'.format(subject), cor_lst)

    return data
Exemplo n.º 10
0
def load(device_fp, activity_fp):
    df_act = _load_activities(activity_fp)
    df_dev = _load_devices(device_fp)

    # correct overlapping activities as going to toilet is done in parallel
    # for this dataset >:/
    df_act, cor_lst = correct_activities(df_act)

    # correct possible duplicates for representation 2
    df_dev, df_dev_rep3 = correct_devices(df_dev)

    data = Data(df_act, df_dev)

    data.df_dev_rep3 = df_dev_rep3
    data.correction_activities = cor_lst

    return data
Exemplo n.º 11
0
    def load_casas_aruba(folder_path):
        _fix_data(os.path.join(folder_path, "data"))

        data_path = os.path.join(folder_path, 'corrected_data.csv')

        df = _load_df(data_path)
        df_dev = _get_devices_df(df)
        df_act = _get_activity_df(df)

        df_dev = correct_devices(df_dev)
        df_act, cor_lst = correct_activities(df_act)

        lst_act = df_act[ACTIVITY].unique()
        lst_dev = df_dev[DEVICE].unique()

        data = Data(df_act, df_dev, activity_list=lst_act, device_list=lst_dev)
        return data
Exemplo n.º 12
0
    def load_mitlab(folder_path):
        act_path = os.path.join(folder_path, subject, "Activities.csv")
        dev_path = os.path.join(folder_path, subject, "sensors.csv")
        data_path = os.path.join(folder_path, subject, "activities_data.csv")

        df_dev_map = _load_device_map(dev_path)
        df_act_map = _load_activity_map(act_path)
        df_dev, df_act = _read_data(data_path, df_dev_map, df_act_map)

        df_act, cor_lst = correct_activities(df_act)
        df_dev = correct_devices(df_dev)

        lst_act = df_act[ACTIVITY].unique()
        lst_dev = df_dev[DEVICE].unique()

        data = Data(df_act, df_dev, activity_list=lst_act, device_list=lst_dev)

        data.df_dev_map = df_dev_map
        data.df_act_map = df_act_map

        if retain_corrections:
            data.correction_activities = cor_lst

        return data