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

StandardScaler in dataprocessing #16

Open
BinhMinhs10 opened this issue Oct 30, 2019 · 1 comment
Open

StandardScaler in dataprocessing #16

BinhMinhs10 opened this issue Oct 30, 2019 · 1 comment

Comments

@BinhMinhs10
Copy link

BinhMinhs10 commented Oct 30, 2019

dùng hàm StandardScaler để chuẩn hóa dữ liệu đầu vào là dataframe nhưng nó trả về numpy.array. Nếu dùng pd.Dataframe() thì mất tên cột mặc dù chuyển được từ numpy về dataframe

one easy way by using Pandas: (here I want to use mean normalization)
normalized_df=(df-df.mean())/df.std()
to use min-max normalization:
normalized_df=(df-df.min())/(df.max()-df.min())

Nhưng thời gian normal và ram tốn nhiều, vậy có cách nào hay hơn để chuẩn hóa mà đầu ra vẫn ở dạng dataframe không?

@bangoc123
Copy link
Owner

Bạn ơi mình có thể giữ lại index và tên columns của dataframe. Sau khi chuẩn hoá mình convert numpy array ngược lại thành dataframe nếu cần:

X_train_data_frame = pd.DataFrame(X_train_is_numpy_array, index=X_train.index, columns=X_train.columns)

Kết quả:

Screen Shot 2019-11-01 at 8 45 11 AM

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