cursor.execute("SELECT open_time FROM rounds WHERE number = {}".format(round_number))
rounds = cursor.fetchall()
round_open_time = rounds[0]
print(round_open_time)
// Get the truth data
public_targets_db = connect_to_public_targets_db()
validation_data = pd.read_sql("SELECT id, target FROM tournament_daily_encrypted WHERE date = "{}" AND data_type = "validation"".format(), public_targets_db)
After Change
// Calculate logloss
submission_validation_data = submission.loc[submission["id"].isin(validation_data["id"].as_matrix())].copy()
submission_validation_data.sort_values("id", inplace=True)
submission_test_data = submission.loc[submission["id"].isin(test_data["id"].as_matrix())].copy()
submission_test_data.sort_values("id", inplace=True)
validation_logloss = log_loss(validation_data["target"].as_matrix(), submission_validation_data["probability"].as_matrix())
test_logloss = log_loss(test_data["target"].as_matrix(), submission_test_data["probability"].as_matrix())
// Get the submission Postgres id
query = "SELECT s.id FROM submissions s INNER JOIN users u ON s.user_id = u.id WHERE u.username = "{}" AND s.inserted_at = "{}"".format(mongo_submission["username"], mongo_submission["created"])
cursor.execute(query)
submission_id = cursor.fetchone()[0]
query = "UPDATE submissions SET validation_logloss={}, test_logloss={} WHERE id = "{}"".format(validation_logloss, test_logloss, submission_id)
cursor.execute(query)
print("Updated {} with validation_logloss={} and test_logloss={}".format(submission_id, validation_logloss, test_logloss))
postgres_db.commit()
cursor.close()