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

Transform decorator #29

Merged
merged 3 commits into from
Oct 12, 2024
Merged

Transform decorator #29

merged 3 commits into from
Oct 12, 2024

Conversation

MatsMoll
Copy link
Owner

@MatsMoll MatsMoll commented Oct 12, 2024

Made it easier to add different types of udfs

@feature_view(source=InMemorySource.empty())
class CombinedData:
    query = String()
    contains_mr = query.contains('mr')

    @transform_polars(using_features=[query], return_type=Bool())
    def contains_something(self, df: pl.LazyFrame, return_value: str) -> pl.LazyFrame:
        return df.with_columns((pl.col('query').str.len_chars() > 5).alias(return_value))

    @transform_pandas(using_features=[query], return_type=String())
    def append_someting(self, df: pd.DataFrame) -> pd.Series:
        return df['query'] + ' something'

    @transform_row(using_features=[query], return_type=String())
    def using_row(self, row: dict) -> str:
        return row['query'] + ' something'

    not_contains = contains_something.not_equals(True)

Also made it easier to switch between a model's output source and when to use the exposed model with

# Reading from the output source
using_source = store.model(MyModel).predict_over(...)

# Sending the input features to a model
use_model_store = store.without_model_cache()
preds_sent_to_model = use_model_store.model(MyModel).predict_over(...)

@MatsMoll MatsMoll merged commit b441458 into main Oct 12, 2024
1 check passed
@MatsMoll MatsMoll deleted the matsei/transform-decorator branch October 12, 2024 18:25
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

Successfully merging this pull request may close these issues.

1 participant