make_datasets.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:PersonalizedMultitaskLearning 作者: mitmedialab 项目源码 文件源码
def getWellbeingTaskListFromDataset(datafile, data_path=PATH_TO_DATASETS, subdivide_phys=True):
    df = pd.DataFrame.from_csv(data_path + datafile)
    wanted_labels = [x for x in df.columns.values if '_Label' in x and 'tomorrow_' in x and 'Evening' in x and 'Alertness' not in x and 'Energy' not in x]
    wanted_feats = [x for x in df.columns.values if x != 'user_id' and x != 'timestamp' and x!= 'dataset' and x!='Cluster' and '_Label' not in x]

    core_name = getDatasetCoreName(datafile)

    modality_dict = getModalityDict(wanted_feats, subdivide_phys=subdivide_phys)

    for dataset in ['Train','Val','Test']:
        task_dict_list = []
        for target_label in wanted_labels: 
            mini_df = helper.normalizeAndFillDataDf(df, wanted_feats, [target_label], suppress_output=True)
            mini_df.reindex(np.random.permutation(mini_df.index))

            X,y = helper.getTensorFlowMatrixData(mini_df, wanted_feats, [target_label], dataset=dataset, single_output=True)
            task_dict = dict()
            task_dict['X'] = X
            task_dict['Y'] = y
            task_dict['Name'] = target_label
            task_dict['ModalityDict'] = modality_dict
            task_dict_list.append(task_dict)
        pickle.dump(task_dict_list, open(data_path + "datasetTaskList-" + core_name + "_" + dataset + ".p","wb"))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号