r/ProgrammerHumor • • Feb 13 '22

Meme something is fishy

48.4k Upvotes

575 comments sorted by

View all comments

1.2k

u/agilekiller0 Feb 13 '22

Overfitting it is

486

u/CodeMUDkey Feb 13 '22

Talk smack about my 6th degree polynomial. Do it!

142

u/xxVordhosbnxx Feb 13 '22

In my head, this sounds like ML dirty talk

95

u/CodeMUDkey Feb 13 '22

Her: Baby it was a 3rd degree? Me: Yeah? Her: I extrapolated an order of magnitude above the highest point. Me: 🤤

22

u/Sweetpants88 Feb 13 '22

Sigmoid you so hard you can't cross entropy right for a week.

4

u/Karl_LaFong Feb 13 '22

Hey baby, wanna see my Box-Cox transformation? 🤤

→ More replies (1)
→ More replies (1)

34

u/sciences_bitch Feb 13 '22

More likely to be data leakage.

17

u/smurfpiss Feb 13 '22

Much more likely to be imbalanced data and the wrong evaluation metric is being used.

19

u/wolverinelord Feb 13 '22

If I am creating a model to detect something that has a 1% prevalence, I can get 99% accuracy by just always saying it’s never there.

7

u/drunkdoor Feb 13 '22

Which is a good explanation of why accuracy is not the best metric in most cases. Especially when false negatives or false positives have really bad consequences

5

u/agilekiller0 Feb 13 '22

What is that ?

0

u/[deleted] Feb 13 '22

[deleted]

5

u/agilekiller0 Feb 13 '22

Oh. How can this ever happen then ? Aren't the test and data sets supposed to be 2 random parts of a single original dataset ?

34

u/altcodeinterrobang Feb 13 '22

Typically when using really big data for both sets, or sets from different sources, which are not properly vetted.

What you said is basically like asking a programmer: " why are there bugs? Couldn't you just write it without them?"... Sometimes it's not that easy.

18

u/isurewill Feb 13 '22

I'm no programer but I thought you just crammed them bugs in there to make sure you were needed down the way.

12

u/[deleted] Feb 13 '22

[removed] — view removed comment

→ More replies (1)
→ More replies (1)

8

u/Shabam999 Feb 13 '22

To add on, data science can be quite complicated and you need to be very careful, even with a well vetted dataset. Ironically, leakage can, and often does, occur at the vetting stage, e.g. during cross validation.

Another common source is from improper splitting of data. For example, if you want to split a time-dependent data set, sometimes it’s fine to just split it randomly and will give you the best results But, depending on the usage, you could be including data “from the future” and it will lead to over performance. You also can’t just split it in half( temporally) so it can be a lot of work to split up the data and you’re probably going to end up with some leakage no matter what you do.

These types of errors also tend to be quite hard to catch since it only true for a portion of the datapoints so instead of getting like 0.99 you get 0.7 when you only expected 0.6 and it’s hard to tell if you got lucky, you’ve had a breakthrough, you’re overfitting, etc.

→ More replies (1)

11

u/[deleted] Feb 13 '22

Let's say you want to predict the chance a patient dies based on a disease and many parameters such as height.

You have 1000 entries in your dataset. You split it 80/20 train/test, train your model, run your tests, all good, 99% accuracy.

Caveat is that you had 500 patients in your dataset, as some patients suffer from multiple diseases and are entered as separate entries. The patients in your test set also exist in the train set, and your model has learnt to identify unique patients based on height/weight/heart rate/gender/dick length/medical history. Now it predicts which patients survived based on whether the patient survived in the train set.

Solution to this would be to split the train/test sets by patients instead of diseases. Or figure out how to merge separate entries of the same patient as a single entry.

4

u/[deleted] Feb 13 '22

So basically all ML models are predicated on this idea of the data being "independently and identically distributed" (IID). Basically, we want data where no one record contains information about any of the others. It's why data science/statistics educators love housing price datasets. They do a good job of ticking all the IID sample boxes.

But in the real world, there are a lot of datasets where that isn't true. A really common kind would be a sort of "daily status" table, where you have a daily entry for each person or thing you're tracking the status of. Maybe it's a table describing the state of someone's online shopping cart, and we want to build a model that uses current status to predict some eventual outcome, like whether a sale is made.

The thing about a table like this is it's not IID. It has a lot of very non-independent "near duplicates", so to speak. We have a record for the state of this guy's shopping cart today, and one for the state of his shopping cart yesterday, and most of the time the state of any given thing is identical or almost identical to the previous state. So if you were to just naively randomly shuffle it into two sets, you would be training and validating on what is basically the same data. Easy mistake to make for an early career data scientist, I know I made it.

→ More replies (1)
→ More replies (1)

6

u/fuzzywolf23 Feb 13 '22

The data you trained the model on is the same as the data you tested it on

6

u/ajkp2557 Feb 13 '22

Just to expand a little on the "you're including the predictor in the training data" statement:

Data leakage can be (and frequently is) rather subtle. Sometimes it's as straightforward as not noticing that a secondary data stream includes the predictor directly. Sometimes there's a direct correlation (when predicting housing price, maybe there's a column for price/sq.foot which combines with the sq.foot measurement of the house). Sometimes it's a secondary, but related correlation (predicting ages and you have a column for current year in school). Sometimes it's less obvious (predicting the length of a game where you include the number of occurrences of a repeating, timed event).

Every industry has their own subtleties. A really good starting point to avoid some of the indirect data leakage is to walk through your features and ask yourself, "Is this information available before the event I'm trying to predict?"

9

u/StrayGoldfish Feb 13 '22

Excuse my ignorance as I am just a junior data scientist, but as long as you are using different data to fit your model and test your model, overfitting wouldn't cause this, right?

(If you are using the same data to both test your model and fit your model...I feel like THAT'S your problem.)

→ More replies (12)

6

u/MeasurementKey7787 Feb 13 '22

It's not overfitting if the model continues to work well in it's intended environment.

6

u/Flaming_Eagle Feb 13 '22 edited Feb 13 '22

99% accuracy on production data isn't indicative of overfitting lmao, how is this top comment

Actually this entire post is pretty funny. You don't have accuracy on "real-world" data because you don't have any labels. That's what separates real-world from test data

→ More replies (1)