4707229d41b18ac74ff186bf9a6874035c378719,common.py,,update_loglosses,#,69

Before Change


    test_logloss = log_loss(test_data["target"].as_matrix(), submission_test_data["probability"].as_matrix())

    // TODO: Get the postgres submission id
    cursor.execute("UPDATE submissions SET validation_logloss={} AND test_logloss={} WHERE id = "{}"".format(validation_logloss, test_logloss, ))
    postgres_db.commit()
    cursor.close()
    postgres_db.close()

After Change


    test_data.sort_values("id", inplace=True)

    // 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()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 3

Instances


Project Name: numerai/submission-criteria
Commit Name: 4707229d41b18ac74ff186bf9a6874035c378719
Time: 2017-11-10
Author: xander@numer.ai
File Name: common.py
Class Name:
Method Name: update_loglosses


Project Name: datascienceinc/Skater
Commit Name: 8c6336d24b905d39f88396e50c8cb23870c38bfe
Time: 2018-02-18
Author: pramitchoudhary@ip-172-30-0-2.us-west-2.compute.internal
File Name: skater/core/global_interpretation/interpretable_models/rule_lists.py
Class Name: BayesianRuleLists
Method Name: discretizer


Project Name: scikit-learn/scikit-learn
Commit Name: fc06baef499b8e0a6d677d4a19fa983f173ad06c
Time: 2020-07-28
Author: 34657725+jeremiedbb@users.noreply.github.com
File Name: sklearn/cluster/_kmeans.py
Class Name:
Method Name: _kmeans_single_lloyd


Project Name: zegami/image-similarity-clustering
Commit Name: 87357e38b749168c806ed57614e08ad9771b191c
Time: 2020-10-14
Author: douglawrence0010@gmail.com
File Name: tsne_reducer.py
Class Name:
Method Name: tsne