0
$\begingroup$

I have a small dataset that has 66 samples and 19 features. It is a numerical and tabular dataset. The goal is to predict a value according to these 19 features. The data is about a medical physics parameter about the lungs. Since the lung has a great difference in different people, this number also changes drastically in different people, so according to the iqr method, 50% of the data are considered outliers. As a result, I have to remove or replace a large amount of data, which causes severe weakness in the results of the models. Do you have any suggestions on this matter?

this is thee code that is used for IQR:

def remove_outliers(df):
    for column in df.columns:
        Q1 = df[column].quantile(0.25)
        Q3 = df[column].quantile(0.75)
        IQR = Q3 - Q1
        lower_bound = Q1 -5  * IQR
        upper_bound = Q3 + 5 * IQR
        
        df = df[(df[column] >= lower_bound) & (df[column] <= upper_bound)]
    return df

X_cleaned = remove_outliers(X)
print(X_cleaned.shape)
$\endgroup$

1 Answer 1

2
$\begingroup$

Do you have any suggestions on this matter?

Glib answer: don't use IQR to remove outliers on that data.

I think if you plot your data distribution you will find it is very much not-normal. I think I'd want to see a plot, and understand from a domain expert what the numbers mean before suggesting what you should use. But taking logs first comes to mind.

I tried to find a reference saying only using IQR on data that is normally distributed, but people are reluctant to say it that distinctly. E.g. https://stats.stackexchange.com/q/580580/5503

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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