# What to code the classification rate and what does it mean?

**URL:** <https://community.drivendata.org/t/what-to-code-the-classification-rate-and-what-does-it-mean/639>\
**Category:** Pump it Up: Data Mining the Water Table\
**Created:** [June 8, 2016, 2:46pm UTC](https://community.drivendata.org/t/what-to-code-the-classification-rate-and-what-does-it-mean/639 "2016-06-08T14:46:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![allenkei](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@allenkei](https://community.drivendata.org/u/allenkei)\
**Post date:** [June 8, 2016, 2:46pm UTC](https://community.drivendata.org/t/what-to-code-the-classification-rate-and-what-does-it-mean/639/1 "2016-06-08T14:46:11Z")

</div>

Hi all,

This is my first time in a competition. I am wondering what does the classification rate mean?

classification rate = (1/N) \* I( y = y\_hat )

I don’t understand if y is equal to y\_hat, then I( y = y\_hat ) return 1 or 0. Or it is the other way around? How can I code this into R?

Thank you so much for helping me in advance. This is my first time in a competition, so I hope I did not sound silly for asking a question like this. Thanks!

---

<div class="post-metadata">

**Author:** ![benedekrozemberczki](https://avatars.discourse-cdn.com/v4/letter/b/edb3f5/32.png) [@benedekrozemberczki](https://community.drivendata.org/u/benedekrozemberczki)\
**Post date:** [July 8, 2016, 12:45pm UTC](https://community.drivendata.org/t/what-to-code-the-classification-rate-and-what-does-it-mean/639/2 "2016-07-08T12:45:44Z")

</div>

It is 1 minus the error rate.

---

<div class="post-metadata">

**Author:** ![jacob\_benoot](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@jacob\_benoot](https://community.drivendata.org/u/jacob_benoot)\
**Post date:** [October 20, 2016, 12:11pm UTC](https://community.drivendata.org/t/what-to-code-the-classification-rate-and-what-does-it-mean/639/3 "2016-10-20T12:11:18Z")

</div>

Hey

I coded this in R by looking at the description:

> The metric used for this competition is the classification rate, which calculates the percentage of rows where the predicted class y^y^ in the submission matches the actual class, yy in the test set.

In other words, it’s the percentage correctly classified.  
I did it like this:

1. Calculate number of rows where your prediction was correct. In my case, I have a data.table with the `id,` the `predicted` class and the `real` class. Then count the number where `predicted` == `real`,

2. Divide by number of rows on which you predict. ( `nrow()` )

Kind regards  
Jbnt
