feat: Group Transformer

Đang mở
#290 8 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Lĩnh vực
data, machine-learning

Hướng nghiên cứu

The issue names no files, so start by locating where the library's existing sklearn-compatible transformers are defined and how they follow fit and transform. The proposal is a GroupTransform that stores per-category aggregates in fit and merges them back in transform, but it leaves open whether inputs are DataFrames or ndarrays, and how unseen categories are handled. Settle those choices with the maintainers first; done means a fitted transformer returns the grouped aggregate merged onto the input, with tests for the chosen behaviour.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Is your feature request related to a problem? Please describe.
Aggregating variables by a single or multiple category is a simple task

df.groupby('cat')["num_var"].transform("mean")  

however to make it compatible with a Sklearn Pipeline, a Transformer with some requirements is needed. Feature Engine could provide a transformer with these functionality.

Describe the solution you'd like

A GroupTransform class with a fit() that stores that computes and stores the aggregated information
and a transform method that merges this information.

Class GroupTransform:

    def fit(X, y=None):
        self.X_agg_ = X.groupby('cat')["num_var"].transform("mean") 

    def transform(X, y=None):
        X.merge(self.X_agg_)

Describe alternatives you've considered
To make it 100% compatible with sklearn the fit and transform methods should takes as input an ndarray.
To pass the information to a new dataframe the merge method is needed.

Ngôn ngữ chính
Python
Star
2.3k
Fork
391
Merge trung bình
11 giờ 34 phút
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của feature-engine/feature_engine

Tất cả issue của feature-engine/feature_engine

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.