Go to Post There MUST BE room for mistakes. That’s one of the best ways to learn. - Ken Leung [more]
Home
Go Back   Chief Delphi > Competition > Rules/Strategy > Scouting
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Old 22-09-2016, 21:53
sirwin sirwin is offline
Registered User
AKA: Stacy Irwin
FRC #1318 (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: May 2016
Rookie Year: 2016
Location: Bellevue, WA
Posts: 10
sirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of light
R Package for Downloading FIRST API Data

I was interested in both FRC and learning the R language, so I created an R package (firstapiR) to download data from the FIRST API server and convert it to R data frames. Perhaps others might find it interesting.

Here is the link to the github repository that contains the package.

There are instructions on how to set up your R environment and download and install the package in the README section of the repository.

Stacy Irwin
Business Operations Mentor
FRC 1318
Issaquah Robotics Society
Reply With Quote
  #2   Spotlight this post!  
Old 24-09-2016, 07:01
Foster Foster is offline
Engineering Program Management
VRC #8081 (STEMRobotics)
Team Role: Mentor
 
Join Date: Jul 2007
Rookie Year: 2005
Location: Delaware
Posts: 1,387
Foster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond repute
Re: R Package for Downloading FIRST API Data

Thanks for doing this! Easy access to data could spur a new generation of stat mavens. Maybe in 2017 we will see a new OPR.
__________________
Foster - VEX Delaware - 17 teams -- Chief Roboteer STEMRobotics.org
2010 - Mentor of the Year - VEX Clean Sweep World Championship
2006-2016, a decade of doing VEX, time really flies while having fun
Downingtown Area Robotics Web site and VEXMen Team Site come see what we can do for you.
Reply With Quote
  #3   Spotlight this post!  
Old 24-09-2016, 12:18
ngreen ngreen is offline
Registered User
AKA: Nelson Green
FRC #1108 (Panther Robotics)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Paola, KS
Posts: 813
ngreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant futurengreen has a brilliant future
Re: R Package for Downloading FIRST API Data

I installed the package. Right now, I'm a little too busy but I'll try it later.

edit:I've used R some but am no expert. Last year I used clustering in R via Tableau to separate the wheat and chaff. I also liked making Shiny apps and tried to make a scouting app, but didn't end up using it. Most data I pulled from TBA or directly from the FIRST page. I didn't use the API, just direct import. Having some tools to do this in R will be useful. I have been working on getting better at making python programs to access the TBA API, but will give this a try. I don't yet know what will be better with the students, but thanks for adding this.

Last edited by ngreen : 24-09-2016 at 12:23. Reason: add more
Reply With Quote
  #4   Spotlight this post!  
Old 24-09-2016, 19:47
sirwin sirwin is offline
Registered User
AKA: Stacy Irwin
FRC #1318 (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: May 2016
Rookie Year: 2016
Location: Bellevue, WA
Posts: 10
sirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of light
Re: R Package for Downloading FIRST API Data

Thanks for the positive feedback.
Reply With Quote
  #5   Spotlight this post!  
Old 25-09-2016, 10:10
sirwin sirwin is offline
Registered User
AKA: Stacy Irwin
FRC #1318 (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: May 2016
Rookie Year: 2016
Location: Bellevue, WA
Posts: 10
sirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of light
Re: R Package for Downloading FIRST API Data

ngreen, let me know if you run into any glitches with the package, either here or in the issues section of the github repository. I was only able to test it on a couple different computers.

I considered both R and Python with the Pandas package for developing this package, and I initially played around with the FIRST API in both languages. I think Python is better as a general purpose scripting language and I found the documentation for Python to be much easier to understand than R's documentation. But for some random reason, early on, I made more progress in R than in Python.

I'm experimenting with a Shiney app as well. I think Shiney could work well for building an application to present our scouting data to the drive crew -- I'm going to see if our scouting group is interested in pursuing that project. If we come up with any interesting R data visualization techniques we'll post them on the github webpages for the firstapiR package.
Reply With Quote
  #6   Spotlight this post!  
Old 29-09-2016, 22:45
Conor Ryan Conor Ryan is offline
I'm parking robot yacht club.
FRC #4571 (Robot Yacht Club)
Team Role: Mentor
 
Join Date: Nov 2004
Rookie Year: 2004
Location: Midtown, NYC
Posts: 1,889
Conor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond reputeConor Ryan has a reputation beyond repute
Re: R Package for Downloading FIRST API Data

Thanks for starting the API! With the right community for R, we can really bring the beginnings of data science to the masses. Machine Learning for alliance selection? K-Means for determining balanced alliances? We can really go a step further here than what exists today.

Quote:
Originally Posted by sirwin View Post
I'm experimenting with a Shiney app as well. I think Shiney could work well for building an application to present our scouting data to the drive crew -- I'm going to see if our scouting group is interested in pursuing that project. If we come up with any interesting R data visualization techniques we'll post them on the github webpages for the firstapiR package.
I've been doing a lot of work with Rshiny for work lately and it is easily the best interface for rapid prototyping of R data applications. Highly recommended, in 20 minutes you can have a quality interface. If you get proficient at it there are a lot of great job opportunities out there.

After R the next leap forward is Scala, but this is a great place to be today.
Reply With Quote
  #7   Spotlight this post!  
Old 30-09-2016, 11:17
Bald & Bearded Bald & Bearded is offline
Jack of All Trades/Master on none
FRC #1885 (ILITE Robotics)
Team Role: Mentor
 
Join Date: Sep 2013
Rookie Year: 2007
Location: United States
Posts: 52
Bald & Bearded is on a distinguished road
Re: R Package for Downloading FIRST API Data

Thanks for posting this. I had been thinking about something along R analysis of match data and a Shiny based scouting system. This is perfect.

One question, I looked at the whole API project on Teamforg and joined the project. But it was not clear if that automatically would get me an authorization token, or if there was some other way one had to go about requesting one.
Reply With Quote
  #8   Spotlight this post!  
Old 30-09-2016, 15:29
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: R Package for Downloading FIRST API Data


Thanks for doing this.

Question for R gurus:

Attached is a table of qual match scores for 17842 alliances (8921 matches) involving 2696 teams.

Each row has 8 fields:

red1 red2 red3 blue1 blue2 blue3 red_score blue_score

What is the recommended way to use R to efficiently compute "World OPR" for this large dataset?


Attached Files
File Type: zip 8col.zip (104.4 KB, 15 views)

Last edited by Ether : 30-09-2016 at 15:41. Reason: added attachment
Reply With Quote
  #9   Spotlight this post!  
Old 02-10-2016, 20:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: R Package for Downloading FIRST API Data

Quote:
Originally Posted by Ether View Post

Thanks for doing this.

Question for R gurus:


Here's a re-statement of the question to make it accessible to R gurus who may not be familiar with OPR computation.

I want to know if R can solve for the least-squares solution to the overdetermined system of linear equations [A][x] = [b], given the attached [A] and [b] files.

An equivalent question framed in the language of statistics would be: [A] is a table (in plaintext sparse format) of 17842 sets of values for 2696 independent variables, and b is a column of 17842 corresponding values for the dependent variable. Can R read the attached files and compute multiple linear regression?


Attached Files
File Type: zip A_and_b.zip (129.2 KB, 8 views)
Reply With Quote
  #10   Spotlight this post!  
Old 04-10-2016, 16:49
sirwin sirwin is offline
Registered User
AKA: Stacy Irwin
FRC #1318 (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: May 2016
Rookie Year: 2016
Location: Bellevue, WA
Posts: 10
sirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of light
Re: R Package for Downloading FIRST API Data

Quote:
Originally Posted by Bald & Bearded View Post
Thanks for posting this. I had been thinking about something along R analysis of match data and a Shiny based scouting system. This is perfect.

One question, I looked at the whole API project on Teamforg and joined the project. But it was not clear if that automatically would get me an authorization token, or if there was some other way one had to go about requesting one.
It's been a few months, but I'm pretty sure that I received my token by joining the teamforge project. I received an email from Alex Herreid a few days later at the email address I used to join the project. The email contained my username and token.

According to the TeamForge page, they'll only be reviewing requests for tokens monthly now that the competition season is over, but they'll review weekly once build season starts up again. It may be a few weeks before you hear from Alex.
Reply With Quote
  #11   Spotlight this post!  
Old 04-10-2016, 17:14
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: R Package for Downloading FIRST API Data



I'd like to hear from anyone who has successfully computed World OPR using R.


Reply With Quote
  #12   Spotlight this post!  
Old 05-10-2016, 15:42
sirwin sirwin is offline
Registered User
AKA: Stacy Irwin
FRC #1318 (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: May 2016
Rookie Year: 2016
Location: Bellevue, WA
Posts: 10
sirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of light
Re: R Package for Downloading FIRST API Data

Quote:
Originally Posted by Ether View Post


I'd like to hear from anyone who has successfully computed World OPR using R.


I'm intrigued. I'm relatively new to FIRST, so bear with me. OPR refers to offensive power rating, correct? You're referring to using the Choleski decomposition to produce an estimate of how many points any single team should be expected to contribute to an alliance score, based on past performance?

There's an R package that supposedly does this -- it's called optR and it's available on the CRAN repository. It has a function called choleskilm that should do the trick. Of course the raw data has to be shaped into a positive definite matrix first.

The size of the matrix could be a problem. The description that I found on this method for calculating OPR focused on using this method for data from a single competition -- generally no more than a 100 x 100 matrix. But 2700 x 2700? I'll experiment with smaller data sets over the weekend and see if I can figure out what the computation time will be.
Reply With Quote
  #13   Spotlight this post!  
Old 07-10-2016, 15:36
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: R Package for Downloading FIRST API Data

Quote:
Originally Posted by sirwin View Post
I'm intrigued. I'm relatively new to FIRST...
Welcome!

Quote:
so bear with me.
Not to worry.

Quote:
OPR refers to offensive power rating, correct?
yes

Quote:
You're referring to using the Choleski decomposition
I did not explicitly mention Cholesky, but yes that factorization can be used to factor the Normal Equations matrix

Quote:
to produce an estimate of how many points any single team should be expected to contribute to an alliance score, based on past performance?
Yes. A very rough estimate, since the model assumptions are not very realistic.

Quote:
There's an R package that supposedly does this -- it's called optR and it's available on the CRAN repository. It has a function called choleskilm that should do the trick.
For small matrix associated with a single event

Quote:
Of course the raw data has to be shaped into a positive definite matrix first.
... AND the Aij design matrix (attached to post9 in this thread) must be read by R before it can be used to compute the normal equations matrix N.

Quote:
The size of the matrix could be a problem.
A big problem

Quote:
The description that I found on this method for calculating OPR focused on using this method for data from a single competition -- generally no more than a 100 x 100 matrix.
Yes.

Quote:
But 2700 x 2700?
Full-matrix Cholesky is roughly proportional to O(n^3).

(2696/40)^3 = 306182

Big problem. Unless you use sparse matrix algorithms.

Quote:
I'll experiment with smaller data sets over the weekend and see if I can figure out what the computation time will be.
Please let us know what you find out


Reply With Quote
  #14   Spotlight this post!  
Old 16-10-2016, 10:46
sirwin sirwin is offline
Registered User
AKA: Stacy Irwin
FRC #1318 (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: May 2016
Rookie Year: 2016
Location: Bellevue, WA
Posts: 10
sirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of light
Downloadable firstapiR Packages

I've had a request for a downloadable version of the firstapiR package, so that there is another option for obtaining firstapiR that doesn't require the devtools package and installing from github. I've made both a source and binary version of the package available at this website.

The file downloads are hosted on my MediaFire account. I apologize for the adds, but I didn't want to post publicly available links to cloud drives where I keep personal files (and I'm too cheap to pay for add-free downloads ).

Stacy
Reply With Quote
  #15   Spotlight this post!  
Old 16-10-2016, 19:44
sirwin sirwin is offline
Registered User
AKA: Stacy Irwin
FRC #1318 (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: May 2016
Rookie Year: 2016
Location: Bellevue, WA
Posts: 10
sirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of lightsirwin is a glorious beacon of light
Re: R Package for Downloading FIRST API Data

Quote:
Originally Posted by Ether View Post
Thanks for doing this.

Question for R gurus:

Attached is a table of qual match scores for 17842 alliances (8921 matches) involving 2696 teams.

Each row has 8 fields:

red1 red2 red3 blue1 blue2 blue3 red_score blue_score

What is the recommended way to use R to efficiently compute "World OPR" for this large dataset?


I have no idea if this is the recommended way to user R for this sort of calculation, but my solution is posted at https://irwinsnet.github.io/opr.html.

My method requires 13 seconds on a Surface 4 with an i5 process and 8 Gb of memory. It actually takes more time to create the A matrix (9 seconds) than it does to solve for the OPRs once the A and B matrices are prepared (3 seconds). The remaining second is required for reading the data and preparing the B matrix.

The results and source code are available at the link above.

Stacy
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:13.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi