# Including column of indices as predictor for model?

I have a small dataset consisting of 1000 observations (rows), 11 predictors + 1 response (12 columns). It is a toy dataset used for learning purposes in a machine learning class at university -- binary classification (heart disease vs. no heart disease).

I have fitted a logistic regression, SVM, and KNN. However, I am using python and I was deleting some rows corresponding to missing values and outliers I did not want to consider -- doing it with df.drop() and then reset_index(). If you do not set the drop flag of reset_index to true you will get a column in your data frame with the indices you wanted to reset. I accidentally forgot to set the flag to true and when fitting the 3 mentioned models included the column with these indices. This gave me an f1-score of 99-100%. When I realized that I had accidentally included this column, I dropped the column, re-fit and achieved ~ 60-80 percent F1 score with the respective models.

Is there a reason why including this column of indices gets you to 100% F1 score or even accuracy? Is this merely a coincidence that apparently works with the dataset?

Including column of indices as predictor for model?

No, don't include indices. They don't provide any meaningful information about the problem. They are just an enumeration. Take them away.

Is there a reason why including this column of indices gets you to 100% F1 score or even accuracy?

You probably get that when evaluating in train set, in test you wont get that. If you do, then you have a problem with your data (it might be sorted).

What does the underlying algorithm do here? Something like this for a decision tree

if index == 1:
predict =1
if index == 2:
predict =0
.
.
.


As you can see there is no meaningful information about the problem here and the prediction in train will still be zero.

Conclusion: don't use indexes as a training feature.