Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC Fix Wikipedia principal eigenvector example - #34266

Merged
lesteve merged 10 commits into
scikit-learn:mainfrom
ArturoAmorQ:wiki_example
Sep 2, 2026
Merged

DOC Fix Wikipedia principal eigenvector example#34266
lesteve merged 10 commits into
scikit-learn:mainfrom
ArturoAmorQ:wiki_example

Conversation

@ArturoAmorQ

@ArturoAmorQ ArturoAmorQ commented Jun 12, 2026

Copy link
Copy Markdown
Member

Reference Issues/PRs

None

What does this implement/fix? Explain your changes.

This example failed when I tried to run locally because the download writes straight to the target file, so an interrupted transfer leaves an empty (0 KB) file behind.

This PR adds a safe download (using sklearn.datasets.fetch_file) and fixes scores * Xscores @ X, for sparse array multiplication.

It also adds 2 plots: One for the convergence error and the other for the pages with the highest eigenvector centrality.

AI usage disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Research and understanding

Any other comments?

The issue was not noticed before as this example is not run by our CI.

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Comment thread examples/applications/wikipedia_principal_eigenvector.py Outdated
Comment thread examples/applications/wikipedia_principal_eigenvector.py Outdated
@ArturoAmorQ
ArturoAmorQ requested a review from virchan June 23, 2026 10:15

@virchan virchan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks, @ArturoAmorQ!

@ogrisel, could we merge this?

@ArturoAmorQ

Copy link
Copy Markdown
Member Author

I guess @ogrisel already has a lot on his plate, maybe we can just look for someone else's review?

@ArturoAmorQ ArturoAmorQ added the Waiting for Second Reviewer First reviewer is done, need a second one! label Aug 27, 2026
@github-actions github-actions Bot added the CI:Linter failure The linter CI is failing on this PR label Sep 2, 2026
@lesteve

lesteve commented Sep 2, 2026

Copy link
Copy Markdown
Member

Out of interest, @ArturoAmorQ how did you bump into the issue? Do you run each morning a random file from the scikit-learn example gallery 😜? Maybe you used a LLM to try to find examples to improve 🤖?

I pushed a tiny tweak and since the example wasn't taking that much time locally (1min30s) I thought it could be run as part of the doc build so I renamed it to add plot_ which automatically will make it run in the doc build (that's the default convention in sphinx-gallery IIRC).

@lesteve

lesteve commented Sep 2, 2026

Copy link
Copy Markdown
Member

Not sure what happened with the CI linting issue hoping merging main will fix it ...

For completeness, the error was:

### Running cython-lint ###

/home/circleci/project/sklearn/cluster/_dbscan_inner.pyx:31:25: Outer for loop variable 'i' overwritten by inner for-loop target
/home/circleci/project/sklearn/cluster/_k_means_common.pyx:30:9: Loop control variable 'i' not used within the loop body (if this is intended, start the name with an underscore)
/home/circleci/project/sklearn/manifold/_utils.pyx:74:13: Loop control variable 'l' not used within the loop body (if this is intended, start the name with an underscore)
Problems detected by cython-lint, please fix them

@github-actions github-actions Bot removed the CI:Linter failure The linter CI is failing on this PR label Sep 2, 2026
@ArturoAmorQ

ArturoAmorQ commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

Out of interest, @ArturoAmorQ how did you bump into the issue? Do you run each morning a random file from the scikit-learn example gallery 😜? Maybe you used a LLM to try to find examples to improve 🤖?

I bumped into it when experimenting methodologies to rank the recommended examples in our gallery. My initial idea was that more connected examples are more relevant.

I pushed a tiny tweak and since the example wasn't taking that much time locally (1min30s) I thought it could be run as part of the doc build so I renamed it to add plot_ which automatically will make it run in the doc build (that's the default convention in sphinx-gallery IIRC).

It's mostly the first download of the data that is slow.

@lesteve

lesteve commented Sep 2, 2026

Copy link
Copy Markdown
Member

Looking at the CircleCI log, the example when downloading the dataset takes less than 3 minutes which isn't that bad:

    - ../examples/applications/plot_wikipedia_principal_eigenvector.py:                             165.91 sec   0.0 MB

The problem is more the size of the downloaded files that takes 900MB:

❯ du -sh ~/scikit_learn_data/downloads.dbpedia.org/3_5_1_en/*
835M	/home/lesteve/scikit_learn_data/downloads.dbpedia.org/3_5_1_en/page_links_en.nt.bz2
57M	/home/lesteve/scikit_learn_data/downloads.dbpedia.org/3_5_1_en/redirects_en.nt.bz2

That would make the Circle cache at 2-3 times bigger for just a single example, making it slower to upload/download in CircleCI, so in the end I am not sure it's worth it. Also people that run all the examples (not that many but maybe some sprint contributors are instructed to do make html 1) would end up with 900MB more of occupied space, which can be surprising ...

I'll wait for the CircleCI doc to finish, maybe push another commit to see the impact on CircleCI cache and decide whether we rename the example back to what it was i.e. without plot_ so that it isn't run in the doc build.

Footnotes

  1. personally I would never suggest doing that, it takes way too long to run all the examples (45 minutes or so), but I have heard for some maintainers it was simpler to say "build the full doc with make html this way you can generate the full build doc and then next runs will be faster"

@lesteve

lesteve commented Sep 2, 2026

Copy link
Copy Markdown
Member

Funnily enough this reminded me of one of my old issue (super-low priority) #8849, where running the Wikipedia example as part of the CI was mentioned 😉.

Comment thread examples/applications/plot_wikipedia_principal_eigenvector.py
@lesteve

lesteve commented Sep 2, 2026

Copy link
Copy Markdown
Member

Looking at the logs the cache doesn't take much time to save/restore in CircleCI (less than seconds), I propose we run it as part of the CI.

The slight downside is that someone doing make html will download an additional 900MB, I think this is acceptable. If somebody disagrees we can always revert the name change to wikipedia_principal_eigenvector.py (i.e. no plot_ at the beginning).

@lesteve
lesteve enabled auto-merge (squash) September 2, 2026 20:31
@lesteve

lesteve commented Sep 2, 2026

Copy link
Copy Markdown
Member

@lesteve
lesteve merged commit ffbd0f8 into scikit-learn:main Sep 2, 2026
35 checks passed
@ArturoAmorQ
ArturoAmorQ deleted the wiki_example branch September 3, 2026 08:11
cboseak pushed a commit to cboseak/scikit-learn that referenced this pull request Sep 4, 2026
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 6, 2026
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 8, 2026
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 8, 2026
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 8, 2026
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants