Skip to content

Applying TimeRolling in LogisticRegression #1600

Open
@cdeterman

Description

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions