Skip to content

Commit b7ce643

Browse files
authored
add a fixed random seed in random table gen sql, in order to get a stable split (#761)
Add a fixed random seed in sql which generating a random table for trainAndValData splitation. With fixed seed, we can keep data splitation return consist trainAndValDataSet.
1 parent 59a4113 commit b7ce643

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql/create_train_val.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func createMaxcomputeRandomTable(target, slct string, db *DB) error {
8585
return e
8686
}
8787
// create a table, then split it into train and val tables
88-
stmt := fmt.Sprintf("CREATE TABLE %s LIFECYCLE %d AS SELECT *, RAND() AS %s FROM (%s) AS %s_ori", target, temporaryTableLifecycle, randomColumn, slct, target)
88+
stmt := fmt.Sprintf("CREATE TABLE %s LIFECYCLE %d AS SELECT *, RAND(42) AS %s FROM (%s) AS %s_ori", target, temporaryTableLifecycle, randomColumn, slct, target)
8989
_, e := db.Exec(stmt)
9090
return e
9191
}
@@ -146,7 +146,7 @@ func createRandomTable(database, table, slct string, db *DB, useCurrentDB bool)
146146
if _, e := db.Exec(dropStmt); e != nil {
147147
return "", e
148148
}
149-
stmt := fmt.Sprintf("CREATE TABLE %s AS SELECT *, RAND() AS %s FROM (%s) AS %s_ori", fullTbl, randomColumn, slct, table)
149+
stmt := fmt.Sprintf("CREATE TABLE %s AS SELECT *, RAND(42) AS %s FROM (%s) AS %s_ori", fullTbl, randomColumn, slct, table)
150150
_, e := db.Exec(stmt)
151151
return fullTbl, e
152152
}

0 commit comments

Comments
 (0)