From the course: Responsible Generative AI and Local LLMs

Coding ELO in R

"

- Here we have Colab Pro, which has a lot of interesting features that you may not be aware of for a Jupyter Notebook that's hosted. One, the runtime is managed for you, which is great. It means you don't have to worry about package management dependency hell. If we take a look at the runtime here first, see that if you go to change runtime type, there are some surprises, right. So one of them is that you can use R inside of Colab. This is a great feature of Colab because it means that if you want to just do statistical programming, it's hard to beat R because it's a language that was designed for statistics. So you can go in here and start to experiment with a language that is a little bit more difficult potentially to devElop with. And that's one of the advantages of Colab Pro. Also, you see we have the hard word acceleration. So we can use CPUs, we can use an A 100 GPU, V100 GPU. So there's the traditional Nvidia GPUs as well as the TensorFlow processing unit, the TPU, this is the homegrown accelerator from Google, and you also can toggle on and off High RAM, which is, which is very useful if you're dealing with larger data. We also can see here that there's Colab Pro. And what's neat about this is I could say, you know, hello world in R and we can get some feedback here that gives us advice. So this is pretty cool that we've got a full fledged, I would call this like a data science type, you know, IEE. And one of the other things that we can do with it is actually dive into programming Elo, which is a strength of schedule metrics. So if we take a look at this, the Elo rating function, it's pretty straightforward to understand, or if, even if you're not familiar with it, we have a function here and it takes two things. It takes a fighter1, fighter2 , and the results. And so what happens here is that we set a default here, fighter1 and fighter2, they're both set to 1500. We set a K factor, which is one of the components of the metric, and then we have a helper expected score function, and then we have a loss or a win conditional statement that tells us how to actually update the metric. And then finally, at the very end, we return back the updated rating. So a pretty straightforward piece of code here. Let's go ahead and run it. There we go. And now, in order to initialize it, what we can do is set these two fighters, fighter1, fighter2, we've got Conor, Khabib, and we can go ahead and run that. And then we can calculate a new rating. So we can just say fighters and it's going to return back both fighters and we can print out the result here. And we can see that the rating is Conor 1475, because he lost and Khabib is 1500 because he won. So this is one of the cool things that you can do with the R language, is actually build a solution inside of Colab share it with other people. And it lets you focus on some of the things that R does well, which is, you know, statistical programming versus only focusing on, you know, maybe getting it set up and libraries, et cetera. So there's some, I think, big advantages to doing our programming instead of Colab Pro.

Inhalt