10 points
*

Image Transcription: Code


bool is_prime(int x)
    return false;
}

[Beneath the code is a snippet of console output, as follows:]

test no.99989: passed
test no.99990: passed
test no.99991: failed
test no.99992: passed
test no.99993: passed
test no.99994: passed
test no.99995: passed
test no.99996: passed
test no.99997: passed
test no.99998: passed
test no.99999: passed
95.121% tests passed

I am a human who transcribes posts to improve accessibility on Lemmy. Transcriptions help people who use screen readers or other assistive technology to use the site. For more information, see here.

permalink
report
reply
7 points

good human

permalink
report
parent
reply
3 points

Why not just test all even numbers greater than 2? It covers infinite numbers and passes 100% of the time.

permalink
report
reply
1 point

It’s important to test edge cases.

permalink
report
parent
reply
1 point

We’ll grab those in integration and E2E tests… let’s just stick with even numbers such that 2 < n < 1002… that’s 1000 cases, more than enough, and 100% test coverage

permalink
report
parent
reply
3 points

You are joking, but this is exactly what happens if you optimize accuracy of an algorithm to classify something when positive cases are very few. The algorithm will simply label everything as negative, and accuracy will be anyway extremely high!

permalink
report
reply
2 points

This is also why medical studies never use accuracy as a measure if the disorder being studied is in any way rare. Sensitivity and specificity or positive/negative likelihood ratios are more common

permalink
report
parent
reply

This is actually a perfect example of why to care about the difference between accuracy, precision, and recall. This algorithm has 0 precision and 0 recall, the only advantage being that it has 100% inverse recall (all negative results are correctly classified as negative).

permalink
report
parent
reply

Illustration of the difference between the two from my machine learning classes in college, which was obviously just the first google result:

permalink
report
parent
reply
2 points

Wow, a neural network!

permalink
report
reply
2 points

Train a neural network to detect non-primes. The more data you give it, the more accurate it is!

permalink
report
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 3.2K

    Monthly active users

  • 1K

    Posts

  • 37K

    Comments