Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fillna continuous data #14

Open
Hahahah3 opened this issue Mar 18, 2022 · 1 comment
Open

fillna continuous data #14

Hahahah3 opened this issue Mar 18, 2022 · 1 comment

Comments

@Hahahah3
Copy link

Hello, I'm a beginner interested in Tabular Learning. Your superb paper, SAINT, impresses me a lot. But I've had some problems learning your code.

For

train.fillna(train.loc[train_indices, col].mean(), inplace=True)
or
X.fillna(X.loc[train_indices, col].mean(), inplace=True)

a) Why is train.loc[train_indices, col] rather than train.loc[:, col]?
Vaild data and test data may also be nan.
b) Why is train.fillna rather than train[col].fillna?
It may fillnan for other columns.

I think the correct expression should be train[col].fillna(train.loc[:, col].mean(), inplace=True).

I'm not sure whether I am correct. I would appreciate it if you can reply. Thank you very much!

@Mountiko
Copy link

Mountiko commented Sep 29, 2022

Hi,
I noticed it, as well.
This original code fills all Nan values across the dataframe with the mean from the first continuous column
X.fillna(X.loc[train_indices, col].mean(), inplace=True)

I would recommend using this code to fill all Nans with the mean of the corresponding column:
X[col].fillna(X.loc[train_indices, col].mean(), inplace=True)

Please feel free to correct me if I am wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants