-
-
Save maqifrnswa/2e2f42f16d58dbf5fc49b34699c86956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import statistics | |
from scipy import optimize | |
#with open("C:/MtgaDraftTool/testing/VOW_QuickDraft_Data.json") as f: | |
with open("C:/MtgaDraftTool/testing/NEO_PremierDraft_Data.json") as f: | |
data = json.load(f) | |
ratings = data["card_ratings"] | |
values= [] | |
for cardid in ratings.keys(): | |
#print(ratings[cardid]["name"]) | |
try: | |
cardrating = ratings[cardid]["deck_colors"]["All Decks"]["gihwr"] | |
if cardrating > 1: | |
values.append(cardrating/100.0) | |
except Exception as e: | |
print("{}: {}, {}".format(type(e), str(e), ratings[cardid]["name"])) | |
meanval = statistics.mean(values) | |
varianceval = statistics.pvariance(values) | |
print((meanval,varianceval)) | |
def betafit(param, mvalue, vvalue): | |
#mvalue, vvalue = args | |
mean_error = mvalue - param[0]/(param[0]+param[1]) | |
variance_error = vvalue - param[0]*param[1]/ ((param[0]+param[1])**2 )/ (param[0] + param[1]+1) | |
print(mean_error) | |
print(variance_error) | |
return (mean_error/mvalue)**2 + (variance_error/vvalue)**2 | |
sol = optimize.minimize(betafit, [20, 20], args=(meanval, varianceval)) | |
print(sol) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment