Exemple #1
0
def create_fold_column_if_not_exist(h2o_base_table: h2o.H2OFrame,
                                    fold_column: str,
                                    nfolds: int = None) -> h2o.H2OFrame:
    if fold_column and fold_column not in h2o_base_table.col_names:
        h2o_fold_col = h2o_base_table.kfold_column(n_folds=nfolds)
        h2o_fold_col.set_names([fold_column])
        h2o_base_table = h2o_base_table.cbind(h2o_fold_col)
    return h2o_base_table
Exemple #2
0
def add_unique_row_id(h2o_base_table: h2o.H2OFrame):
    num_rows = h2o_base_table.shape[0]

    ids = []
    for id in range(0, num_rows):
        ids.append(id)

    h2o_id_frame = h2o.H2OFrame(ids)
    return h2o_base_table.cbind(h2o_id_frame.set_names(['row_id']))