2
$\begingroup$

In my current pipeline, I have sensed that there is data leakage. This is because the same person, though with slightly different values, is in both training and testing set. As a result, my model is overfitting.

For eg my data looks like this:

PID       Var_1   Var_2
Person A     0      1
Person B     0      1
Person C     0      0
Person A     1      3
Person B     1      2
Person D     0      1 
Person C     0      1    

I want to split this data such that the rows of the same person will be in either training or testing set, i.e I want the split to look like this:

Training:

PID       Var_1   Var_2
Person A     0      1
Person B     0      1
Person A     1      3
Person B     1      2    

Testing:

PID       Var_1   Var_2
Person C     0      0
Person D     0      1  
Person C     0      1   

$\endgroup$
2
$\begingroup$

Figured out an easy way to do this.

  1. First we will just select PID from the real data.
  2. Then we will just sample 0.75 % of these PID and save these point as training PID and the rest as testing PID.
  3. We will thne find the intersection between this list and the real data using PID.
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.