From 233b1dcda3f0e62835feb4cf3a0da849c84773a2 Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Wed, 4 Mar 2020 16:53:25 -0600 Subject: [PATCH] superscript.py v 0.0.1.003 --- data analysis/__pycache__/data.cpython-37.pyc | Bin 3007 -> 2981 bytes .../__pycache__/superscript.cpython-37.pyc | Bin 0 -> 3965 bytes data analysis/data.py | 2 +- data analysis/superscript.py | 69 ++++++++++++++++-- 4 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 data analysis/__pycache__/superscript.cpython-37.pyc diff --git a/data analysis/__pycache__/data.cpython-37.pyc b/data analysis/__pycache__/data.cpython-37.pyc index 3a5788584c97369b15d44cf40f0e2a904a408ebd..6b0bd6cc46924d1ca5adacdcaa0cf379f0de60a1 100644 GIT binary patch delta 1220 zcmah|&2G~`5bnksd!5vwYV+40T2;`dE=5SF;=fPPSqOsCC19&CFSrk%c*64FR$%~UhF*ruNk-kij<Ac@~dHNhG zKA`JRYI%gao{!GG@PgSd37g!<>??b?Jp2qBv>L?COCBlZgm0g zUZWhfW)MSImo*<*meC~1bBqlRhBfs)eY8X>mjM-HBoR<6l2fv3->mljoF?f+| zw`8zo#jS+ku(9McQuw53!wa0{s}4nhx$1{lFt1UltA2~U%R~xR=%^I-m}{dJ`Y=?& z99pU_|JVAyUG9yvo;7v`*~8zgf-kiE%LjGe2xFs@bGW}^f%fW;!ZLQUs z&5#^hOA1#zVH8K&co@d6`jxIoZN{}m=tz|}=H^Vq8?8>PMa?b1;nn>p_B!o=GANjU zrEVDG<$l&v!W5%?iegMG3n{3go*Jv7q<$I|kyo~PspMv_`mukFd|X0Q4%z*KAYDEOKfM-q2F*aG|CDcQAab2x4WgGPXHzX zQ-EWDU3ajmhxq*-YIuz>rdl=f0%keFt_a=!doj(cx0&r3Bs+r8oqdJKX4@?6QoXR2 zH~tejmqao+8Erle*CRT_iZ-Jb#e`?mVK^UtH#u8l{Wk!aBYNhwib`} z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TzLF5!kEC^0>-2m&=?Dt zkAcCbp|qtVVZu{`UU=OZ8fUiVa=|ru3s-B&<$>$PTe#Xwt`4~V{uZw8l4}iI|9T5o zuj10>ufMChNZ%w1^oNDII7)E60vZl`-$Z zNvf~aJ=e5zE=FlnNaYCnh=w+ChFqfv6t}3OsA!}UMd%4y@eVqM+R&-n4ZvoLh?5?w z4V1<@V!n$362;V&z=qx7f20j1gMFQy;o^Db))x*E!W2F5t4mc4Mc@ZICv-3m9B~mu zae=xk)Lo_SUFu%bc^$YvqZL{uvttUvEES}>vQ+S|nAB<^KhG>=|BKRwx__EG$A2sx zZs-gz=Pv3%3!EkuvC=)WI72AirO}e)Z~G9A)^` zjW7Q5o3H-%U|@+4F;}MG$~wwZFkAR#Qr0ltQKl>qEel)Y<2s9<2e^3xTxZcJF4SeZ zujX|I~_^FuUKSp5Os(&y9)wwE%bUKiI1YH;U($p7Ab5$S_enUa6D&0cL qyEo4HG>z}mRa4wVXTN7#wqxSPrPp<++IqHk!}Gig-c`@_Zv79Y;1Nv# literal 0 HcmV?d00001 diff --git a/data analysis/data.py b/data analysis/data.py index f00943cc..fa1f866e 100644 --- a/data analysis/data.py +++ b/data analysis/data.py @@ -61,4 +61,4 @@ def push_team_metrics_data(apikey, competition, team_num, data, dbname = "data_p client = pymongo.MongoClient(apikey) db = client[dbname] mdata = db[colname] - mdata.replace_one({"competition" : competition, "team": team_num}, {"_id": competition+str(team_num)+"am", "competition" : competition, "team" : team_num, "data" : data}, True) \ No newline at end of file + mdata.replace_one({"competition" : competition, "team": team_num}, {"_id": competition+str(team_num)+"am", "competition" : competition, "team" : team_num, "metrics" : data}, True) \ No newline at end of file diff --git a/data analysis/superscript.py b/data analysis/superscript.py index 35cd1ffe..f25c5931 100644 --- a/data analysis/superscript.py +++ b/data analysis/superscript.py @@ -3,10 +3,12 @@ # Notes: # setup: -__version__ = "0.0.1.002" +__version__ = "0.0.1.003" # changelog should be viewed using print(analysis.__changelog__) __changelog__ = """changelog: + 0.0.1.003: + - working 0.0.1.002: - started implement of metrics 0.0.1.001: @@ -61,12 +63,19 @@ from analysis import analysis as an import data as d import time -main() +def testing(): + + competition, config = load_config("config.csv") + + apikey = an.load_csv("keys.txt")[0][0] + tbakey = an.load_csv("keys.txt")[1][0] + + metricsloop(tbakey, apikey, "2020mokc", 1583084980) def main(): while(True): current_time = time.time() - print("time: " + time) + print("time: " + str(current_time)) print("loading config") competition, config = load_config("config.csv") @@ -147,8 +156,56 @@ def push_to_database(apikey, competition, results, metrics): d.push_team_tests_data(apikey, competition, team, results[team]) -def metricsloop(apikey, competition, timestamp): # listener based metrics update +def metricsloop(tbakey, apikey, competition, timestamp): # listener based metrics update - matches = d.pull_new_tba_matches(apikey, competition, timestamp) + matches = d.pull_new_tba_matches(tbakey, competition, timestamp) - return \ No newline at end of file + red = load_metrics(apikey, competition, matches, "red") + blu = load_metrics(apikey, competition, matches, "blue") + + return + +def load_metrics(apikey, competition, matches, group_name): + + for match in matches: + + for team in match[group_name]: + + group = {} + + db_data = d.get_team_metrics_data(apikey, competition, team) + + if d.get_team_metrics_data(apikey, competition, team) == None: + + elo = {"score": 1500, "N": 1500, "K": 1500} + gl2 = {"score": 1500, "rd": 250, "vol": 0.06} + ts = {"mu": 25, "sigma": 25/3} + + d.push_team_metrics_data(apikey, competition, team, {"elo":elo, "gliko2":gl2,"trueskill":ts}) + + group[team] = {"elo": elo, "gl2": gl2, "ts": ts} + + else: + + metrics = db_data["metrics"] + elo = metrics["elo"] + gl2 = metrics["gliko2"] + ts = metrics["trueskill"] + + group[team] = {"elo": elo, "gl2": gl2, "ts": ts} + + return group + +testing() + +""" +Metrics Defaults: + +elo starting score = 1500 +elo N = 1500 +elo K = 32 + +gl2 starting score = 1500 +gl2 starting rd = 350 +gl2 starting vol = 0.06 +""" \ No newline at end of file