Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

docs: add snippets for Matrix Factorization tutorials#1630

Merged
tswast merged 37 commits intomainfrom
b338873783-mf-snippets
May 8, 2025
Merged

docs: add snippets for Matrix Factorization tutorials#1630
tswast merged 37 commits intomainfrom
b338873783-mf-snippets

Conversation

@rey-esp
Copy link
Copy Markdown
Contributor

@rey-esp rey-esp commented Apr 18, 2025

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. samples Issues that are directly related to samples. labels Apr 18, 2025
@rey-esp rey-esp requested a review from tswast May 5, 2025 15:01
@tswast tswast marked this pull request as ready for review May 6, 2025 17:30
@snippet-bot
Copy link
Copy Markdown

snippet-bot bot commented May 6, 2025

Here is the summary of changes.

You are about to add 6 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@tswast
Copy link
Copy Markdown
Contributor

tswast commented May 7, 2025

Snippet bot failure looks like a real one:

Edit: I created a suggested commit that I think should fix that.

Comment thread samples/snippets/mf_explicit_model_test.py Outdated
Comment thread samples/snippets/mf_explicit_model_test.py
Comment thread samples/snippets/mf_explicit_model_test.py Outdated
Comment thread samples/snippets/mf_explicit_model_test.py Outdated
Comment thread samples/snippets/mf_explicit_model_test.py Outdated
Comment on lines +127 to +131
# Load movies
movies = bpd.read_gbq("bqml_tutorial.movies")

# Merge the movies df with the previously created predicted df
merged_df = bpd.merge(predicted, movies, left_on="item_id", right_on="movie_id")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

predicted here is only a subset. The SQL shows creating a table of all the predictions.

CREATE OR REPLACE TABLE `bqml_tutorial.recommend`
AS
SELECT
  *
FROM
  ML.RECOMMEND(MODEL `bqml_tutorial.mf_explicit`);

Did we implement a way for predict() to work without any inputs like in the SQL?

Suggested change
# Load movies
movies = bpd.read_gbq("bqml_tutorial.movies")
# Merge the movies df with the previously created predicted df
merged_df = bpd.merge(predicted, movies, left_on="item_id", right_on="movie_id")
predicted = model.predict()
# Load movies
movies = bpd.read_gbq("bqml_tutorial.movies")
# Merge the movies df with the previously created predicted df
merged_df = bpd.merge(predicted, movies, left_on="item_id", right_on="movie_id")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature isn't supported yet and an issue will be filed shortly

rey-esp and others added 3 commits May 7, 2025 14:14
Co-authored-by: Tim Sweña (Swast) <swast@google.com>
Co-authored-by: Tim Sweña (Swast) <swast@google.com>
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 7, 2025
@bigframes-bot bigframes-bot removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 7, 2025
@tswast tswast added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 8, 2025
@bigframes-bot bigframes-bot removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 8, 2025
@tswast tswast enabled auto-merge (squash) May 8, 2025 15:04
@tswast
Copy link
Copy Markdown
Contributor

tswast commented May 8, 2025

Samples tests passed! 🥳

@tswast tswast merged commit 24b37ae into main May 8, 2025
22 of 24 checks passed
@tswast tswast deleted the b338873783-mf-snippets branch May 8, 2025 15:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. samples Issues that are directly related to samples. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants