def store_k_evaluation_measures(store_path,
                                k_list,
                                k_evaluation_measures,
                                feature_column_names):
    number_of_folds = k_evaluation_measures[0].shape[1]

    h5_store = h5_open(store_path + "results.h5")

    for fold_index in range(number_of_folds):
        data_frame = pd.DataFrame(k_evaluation_measures[0][:, fold_index], columns=["kendall_tau"], index=k_list)
        h5store_at(h5_store,
                   "/data/kendall_tau/fold" + str(fold_index),
                   data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[1][:, fold_index], columns=["p_value"], index=k_list)
        h5store_at(h5_store,
                   "/data/p_value/fold" + str(fold_index),
                   data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[2][:, fold_index], columns=["mse"], index=k_list)
        h5store_at(h5_store,
                   "/data/mse/fold" + str(fold_index),
                   data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[3][:, fold_index], columns=["jaccard"], index=k_list)
        h5store_at(h5_store,
                   "/data/top_k_jaccard/fold" + str(fold_index),
                   data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[4][:, fold_index, :], columns=feature_column_names, index=k_list)
        h5store_at(h5_store,
                   "/data/feature_importances/fold" + str(fold_index),
                   data_frame)

    h5_close(h5_store)
def store_dataset_k(dataset_k_path, dataset_k, X_k_min_dict, X_t_next_dict,
                    index):

    h5_store = h5_open(dataset_k_path)

    for osn_name in dataset_k.keys():
        h5store_at(
            h5_store, "/data/" + osn_name + "/X_branching",
            pd.DataFrame(dataset_k[osn_name]["X_branching"],
                         columns=sorted(
                             list(get_branching_feature_names(osn_name)))))
        h5store_at(
            h5_store, "/data/" + osn_name + "/X_usergraph",
            pd.DataFrame(dataset_k[osn_name]["X_usergraph"],
                         columns=sorted(
                             list(get_usergraph_feature_names(osn_name)))))
        h5store_at(
            h5_store, "/data/" + osn_name + "/X_temporal",
            pd.DataFrame(dataset_k[osn_name]["X_temporal"],
                         columns=sorted(
                             list(get_temporal_feature_names(osn_name)))))

        utility_arrays = dict()
        utility_arrays["X_k_min_array"] = X_k_min_dict[osn_name]
        utility_arrays["X_t_next_array"] = X_t_next_dict[osn_name]

        h5store_at(h5_store, "/data/" + osn_name + "/utility_arrays",
                   pd.DataFrame(utility_arrays))

    h5_close(h5_store)
def store_dataset_full(dataset_full_path, dataset_full, index,
                       branching_feature_names_list_dict,
                       usergraph_feature_names_list_dict,
                       temporal_feature_names_list_dict):
    h5_store = h5_open(dataset_full_path)

    for osn_name in dataset_full.keys():
        h5store_at(
            h5_store, "/data/" + osn_name + "/X_branching",
            pd.DataFrame(dataset_full[osn_name]["X_branching"],
                         columns=branching_feature_names_list_dict[osn_name]))
        h5store_at(
            h5_store, "/data/" + osn_name + "/X_usergraph",
            pd.DataFrame(dataset_full[osn_name]["X_usergraph"],
                         columns=usergraph_feature_names_list_dict[osn_name]))
        h5store_at(
            h5_store, "/data/" + osn_name + "/X_temporal",
            pd.DataFrame(dataset_full[osn_name]["X_temporal"],
                         columns=temporal_feature_names_list_dict[osn_name]))

        y_raw_dict = dict()
        for target_name in dataset_full[osn_name]["y_raw"].keys():
            y_raw_dict[target_name] = dataset_full[osn_name]["y_raw"][
                target_name]

        h5store_at(h5_store, "/data/" + osn_name + "/y_raw",
                   pd.DataFrame(y_raw_dict))

    h5_close(h5_store)
def store_dataset_k(dataset_k_path,
                    dataset_k,
                    X_k_min_dict,
                    X_t_next_dict,
                    index):

    h5_store = h5_open(dataset_k_path)

    for osn_name in dataset_k.keys():
        h5store_at(h5_store,
                   "/data/" + osn_name + "/X_branching",
                   pd.DataFrame(dataset_k[osn_name]["X_branching"],
                                columns=sorted(list(get_branching_feature_names(osn_name)))))
        h5store_at(h5_store,
                   "/data/" + osn_name + "/X_usergraph",
                   pd.DataFrame(dataset_k[osn_name]["X_usergraph"],
                                columns=sorted(list(get_usergraph_feature_names(osn_name)))))
        h5store_at(h5_store,
                   "/data/" + osn_name + "/X_temporal",
                   pd.DataFrame(dataset_k[osn_name]["X_temporal"],
                                columns=sorted(list(get_temporal_feature_names(osn_name)))))

        utility_arrays = dict()
        utility_arrays["X_k_min_array"] = X_k_min_dict[osn_name]
        utility_arrays["X_t_next_array"] = X_t_next_dict[osn_name]

        h5store_at(h5_store,
                   "/data/" + osn_name + "/utility_arrays",
                   pd.DataFrame(utility_arrays))

    h5_close(h5_store)
def store_dataset_full(dataset_full_path,
                       dataset_full,
                       index,
                       branching_feature_names_list_dict,
                       usergraph_feature_names_list_dict,
                       temporal_feature_names_list_dict):
    h5_store = h5_open(dataset_full_path)

    for osn_name in dataset_full.keys():
        h5store_at(h5_store,
                   "/data/" + osn_name + "/X_branching",
                   pd.DataFrame(dataset_full[osn_name]["X_branching"],
                                columns=branching_feature_names_list_dict[osn_name]))
        h5store_at(h5_store,
                   "/data/" + osn_name + "/X_usergraph",
                   pd.DataFrame(dataset_full[osn_name]["X_usergraph"],
                                columns=usergraph_feature_names_list_dict[osn_name]))
        h5store_at(h5_store,
                   "/data/" + osn_name + "/X_temporal",
                   pd.DataFrame(dataset_full[osn_name]["X_temporal"],
                                columns=temporal_feature_names_list_dict[osn_name]))

        y_raw_dict = dict()
        for target_name in dataset_full[osn_name]["y_raw"].keys():
            y_raw_dict[target_name] = dataset_full[osn_name]["y_raw"][target_name]

        h5store_at(h5_store,
                   "/data/" + osn_name + "/y_raw",
                   pd.DataFrame(y_raw_dict))

    h5_close(h5_store)
Ejemplo n.º 6
0
def store_k_evaluation_measures(store_path, k_list, k_evaluation_measures,
                                feature_column_names):
    number_of_folds = k_evaluation_measures[0].shape[1]

    h5_store = h5_open(store_path + "results.h5")

    for fold_index in range(number_of_folds):
        data_frame = pd.DataFrame(k_evaluation_measures[0][:, fold_index],
                                  columns=["kendall_tau"],
                                  index=k_list)
        h5store_at(h5_store, "/data/kendall_tau/fold" + str(fold_index),
                   data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[1][:, fold_index],
                                  columns=["p_value"],
                                  index=k_list)
        h5store_at(h5_store, "/data/p_value/fold" + str(fold_index),
                   data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[2][:, fold_index],
                                  columns=["mse"],
                                  index=k_list)
        h5store_at(h5_store, "/data/mse/fold" + str(fold_index), data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[3][:, fold_index],
                                  columns=["jaccard"],
                                  index=k_list)
        h5store_at(h5_store, "/data/top_k_jaccard/fold" + str(fold_index),
                   data_frame)

        data_frame = pd.DataFrame(k_evaluation_measures[4][:, fold_index, :],
                                  columns=feature_column_names,
                                  index=k_list)
        h5store_at(h5_store,
                   "/data/feature_importances/fold" + str(fold_index),
                   data_frame)

    h5_close(h5_store)