|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#1
|
||||
|
||||
|
OPR
Does anyone have a an excel document or something where I can plug in match scores and figure out OPR or how I could put an OPR calculator in an Android App
|
|
#2
|
||||
|
||||
|
Re: OPR
I will be posting a spreadsheet after Week 1 regarding advanced stats including OPR and a few other metrics.
I have done these spreadsheets the last few years and they can be found here: http://www.chiefdelphi.com/media/papers/3003 http://www.chiefdelphi.com/media/papers/2967 In addition, I have an app on the google play store called OPRFIRST2014 that was developed to focus specifically on OPR calculations for android. I released the entire source code for it because TheBlueAlliance began to include OPR calculations in their app and it was too hard to gain users with everyone using thebluealliance.com. So feel free to look through here and use the code to calculate OPR. (Although I may warn you, the code may be a little hard to read because I was just beginning android development and this was the first app I created). https://github.com/mray19027/OPRFIRST2014 The EXACT location of where my OPR calculations take place is here: https://github.com/mray19027/OPRFIRS...Info.java#L305 Last edited by stingray27 : 25-02-2015 at 16:23. |
|
#3
|
||||
|
||||
|
Re: OPR
Ed Law and his team has put together awesome resources for calculating OPR that can be found here.
Calculating OPR isn't actually that hard, although it requires some knowledge about basic linear algebra. Essentially, you are trying to solve a linear system of equations for a certain constant that is what you expect a team to contribute to an alliance each match (OPR). If you have teams a, b, and c playing together in one match, and they score a x amount of points, you are solving a(OPR) + b(OPR) + c(OPR) = x As more matches occur, the matrix equations become more complex. In the form of Ax = b, A is the matrix whose values correspond to the amount of matches teams played with each other, x is the OPR vector, and b is the vector of the total score each team made in all the matches they played. If you don't want to do the hard math/plug in your own match scores, you can use The Blue Alliance's API to get OPRs off their site. |
|
#4
|
||||
|
||||
|
Re: OPR
Quote:
Each element of |b| corresponds to a team, and the value of that element is the sum of the alliance scores for all alliances that team played with. |
|
#5
|
|||||
|
|||||
|
Re: OPR
Quote:
|
|
#6
|
|||||
|
|||||
|
Re: OPR
Quote:
And if you just want to view the data, it is displayed in the TBA Android app, as well (looks like this, but more material. Sorry, old screenshot) Last edited by plnyyanks : 25-02-2015 at 19:42. |
|
#7
|
|||||
|
|||||
|
Re: OPR
Quote:
Hit Code:
/api/v2/event/<event-key>/stats Spoiler for Lots of data:
Last edited by plnyyanks : 25-02-2015 at 19:22. |
|
#8
|
||||
|
||||
|
Re: OPR
Quote:
To solve [M][x]=[s], that code uses numpy.linalg.solve which uses LAPACK routine gesv which does LU decomposition. Since [M] is symmetric positive definite, Cholesky decomposition can be used instead to take advantage of that particular matrix structure. For OPR computation for single events the difference will likely be negligible, but when computing combined OPR for all events for an entire season Cholesky will be noticeably faster than LU. |
|
#9
|
|||||
|
|||||
|
Re: OPR
Quote:
|
|
#10
|
|||||
|
|||||
|
Re: OPR
Quote:
![]() |
|
#11
|
|||||
|
|||||
|
Re: OPR
|
|
#12
|
||||
|
||||
|
Re: OPR
Code:
x = np.linalg.cho_solve(np.linalg.cho_factor(M) , s) |
|
#13
|
||||
|
||||
|
Re: OPR
linalg.cho_factor() and linalg.cho_solve() are in scipy, not numpy.
Attached is a sparse-format "M" matrix generated from this data containing 2,696 teams and 8,921 matches. Can someone with a Python installation please factor that matrix with LU1 and Cholesky2 and report the times? 1scipy.linalg.lu(M) 2scipy.linalg.cho_factor(M) |
|
#14
|
||||
|
||||
|
Re: OPR
Here's some even tastier fruit:
Code:
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
>>> import numpy
>>> import time
>>> import scipy
>>> import scipy.sparse
>>> import scipy.sparse.linalg
>>> # Read M & s ...
>>> M = numpy.loadtxt(open('M.dat'))
>>> s = numpy.loadtxt(open('s.dat'))
>>> end = time.time()
>>> # solve...
... start = time.time()
>>> x = numpy.linalg.solve(M,s)
>>> end = time.time()
>>> print "%f seconds" % (end-start)
15.344000 seconds
>>># solve Cholesky...
... start = time.time()
>>> xc = scipy.linalg.cho_solve(scipy.linalg.cho_factor(M),s)
>>> end = time.time()
>>> print "%f seconds" % (end-start)
1.688000 seconds
>>> # Convert to sparse...
... start = time.time()
>>> Msparse = scipy.sparse.csr_matrix(M)
>>> end = time.time()
>>> print "%f seconds" % (end-start)
0.219000 seconds
>>>
>>> # solve sparse...
... start = time.time()
>>> xs = scipy.sparse.linalg.spsolve(Msparse,s)
>>> end = time.time()
>>> print "%f seconds" % (end-start)
0.468000 seconds
>>>
Last edited by Ether : 27-02-2015 at 12:25. |
|
#15
|
||||
|
||||
|
Re: OPR
Quote:
I think it's useful to understand how OPR works too, because often OPR alone often poorly models the game, or the game includes nonlinear (bins this year) or irrelevant (foul points last year) elements which get lumped into naive OPR equations anyways. You should understand what you're looking at before you take a list of teams ranked by OPR at face value. Last edited by Spoam : 05-03-2015 at 03:06. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|