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

Applying TimeRolling in LogisticRegression #1600

Open
cdeterman opened this issue Aug 28, 2024 · 0 comments
Open

Applying TimeRolling in LogisticRegression #1600

cdeterman opened this issue Aug 28, 2024 · 0 comments

Comments

@cdeterman
Copy link

cdeterman commented Aug 28, 2024

river version: 0.21.2
Python version: 3.10
Operating system: Windows

Describe the bug

Steps/code to reproduce

# Sample code to reproduce the problem
# Please do your best to provide a Minimal, Reproducible Example: https://stackoverflow.com/help/minimal-reproducible-example

def define_model(alpha):
    regression = linear_model.LogisticRegression(intercept_lr=0,
                                                            optimizer=optim.SGD(0.0001),
                                                            loss=optim.losses.Quantile(alpha))

        pipeline = compose.Pipeline(
            # THIS IS THE LOCATION FOR FEATURE ENGINEERING
            ('features', compose.TransformerUnion(
                compose.Select(‘var1’, ‘var2’),
                ('Target_30_days', feature_extraction.TargetAgg(
                    by=['group'],
                    how=utils.TimeRolling(stats.Mean(), dt.timedelta(days=30))
                ))
            )),
            ('scale', preprocessing.StandardScaler()),
            ('lin_reg', preprocessing.TargetStandardScaler(
                regression
            ))
        )
        return pipeline

def train():

        # set streaming data (ultimately want to connect to Kafka)
        sdf = self.rdm.stream_data()
        i = 0

        for idv, target in sdf:
            # get instance date
            t = idv[self.rdm.target_dt]
            
            # Obtain prior prediction and update model in one go
            y_est = model.predict_one(idv)
            
            # learn
            model.learn_one(x=idv, y=target, t=t)

This then throws the error:

TypeError: TimeRolling.update() missing 1 required keyword-only argument: 't'
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

1 participant