feat: Group Transformer

Aperta
#290 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
pandas, python, scikit-learn

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
2.3k
Fork
391
Merge medio
11h 34m
PR unite (30g)
11

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di feature-engine/feature_engine

Tutte le issue di feature-engine/feature_engine

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.