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

Predict in bigquery #59

Closed
joscani opened this issue Oct 26, 2024 · 2 comments · Fixed by #60
Closed

Predict in bigquery #59

joscani opened this issue Oct 26, 2024 · 2 comments · Fixed by #60
Labels
bug an unexpected problem or unintended behavior

Comments

@joscani
Copy link

joscani commented Oct 26, 2024

Hi . I'm trying to predict in bigquery.

With your example of how predit mtcars I get this

mtcars_db <-  sc |> tbl(I("churn2.mtcars"))


rec_spec <- recipe(mpg ~ ., data = mtcars) |>
  step_normalize(all_numeric_predictors())

lm_spec <- linear_reg()

wf_spec <- workflow(rec_spec, lm_spec)

wf_fit <- fit(wf_spec, mtcars)

predict(wf_fit, mtcars)
predict(wf_fit, mtcars_db)


orbital_obj  <- orbital(wf_fit)

predict(orbital_obj, mtcars_db)
Error in `bq_project_query()`:
! Job central-splice-420820.job_M8_0p0iJImfODZZML5tquYZXThxO.us-central1 failed
✖ Invalid field name ".pred". Fields must contain the allowed characters, and be at most 300
  characters long. For allowed characters, please refer to
  https://cloud.google.com/bigquery/docs/schemas#column_names [invalid]
Run `rlang::last_trace()` to see where the error occurred.```

How can I change pred column name from .pred to a proper name? 
Thanks
@EmilHvitfeldt EmilHvitfeldt added the bug an unexpected problem or unintended behavior label Oct 29, 2024
@EmilHvitfeldt
Copy link
Member

thanks for the report! I'll fix this.

the quick fix that should work now is to run the following code

names(orbital_obj)[names(orbital_obj) == ".pred"] <- "pred"

you can make the new name anything you want. and you don't have to install dev version of the package.

@EmilHvitfeldt
Copy link
Member

this PR #60 add a prefix argument that you can use to rename the prediction column(s)

@joscani joscani closed this as completed Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants