-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
DOC Added references to plot_weighted_samples example in SVM documentation #30676
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
DOC Added references to plot_weighted_samples example in SVM documentation #30676
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, @simarssidhu!
I have left you a few comments. Otherwise it's fine.
55520aa
to
0f37ec7
Compare
Hi @StefanieSenger, Thanks for your comments! I've gone ahead and incorporated the suggested changes, and squashed my commits for your review. Please let me know if it looks good now. Thank you! You've been a tremendous help with my first open source contribution! I'll try and tackle some more tomorrow Best, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @simarssidhu, it looks great.
I am just wondering if instead of linking the example here, it would be more valuable to link it in BaseLibSVM.fit()
when the sample_weight
param is described.
Maybe @marenwestermann or @ArturoAmorQ want to have a look at this and continue with the merge of this PR?
(Note: please avoid to force push, because in more complex scenarios, PRs are much easier to review if we can see the history. The PRs are squashed before being merged into main anyways.)
…ikit-learn into svm_plot_weighted_samples
Thanks @StefanieSenger, I've updated the reference, and moved it to the However, I think there might be an issue with my commit history. I've synced my forked origin with the scikit-learn upstream, pulled the changes locally, and committed my update (1188b15). Unfortunately, I noticed some "merge branch" commits (23faac1 and 5da3019) in the process. Normally, I would resolve this locally and force push to my fork to clean up the history. However, since we're avoiding force pushes, I was wondering if you could advise on the best way to proceed in this situation? Thank you, |
Update:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @simarssidhu thanks for the PR. Here are a couple of comments.
Sorry to be a little bitter here, but it's been a while since I stated that this issue has led to a chaotic documentation. Your PR just showed me how much that is the case for svm.SVC
. Currently there is Nested versus non-nested cross-validation linked from the main paragraph, Plot classification probability at the end of the Example
section (section that by the way was originally reserved for snippets, i.e. code that can be easily copied and pasted as warm-start) and now your PR intends to add SVM: Weighted samples to the Notes
section, which by the way is now known to be a very bad practice.
sklearn/svm/_classes.py
Outdated
For a comparison of the SVC with other classifiers see: | ||
:ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! I just noticed there are a few places in the documentation where this particular typo appears. Probably result from copy-pasting from already merged pulled request. Would you feel like fixing those?
Being said that, I don't think the intention of the linked example was to compare SVC
with other classifiers as stated here, but rather to showcase the use of DecisionBoundaryDisplay
when plotting predict_proba
in multiclass classification. I then suggest to completely remove this paragraph, as one day we may use a different set of estimators to serve the real purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it, there is no need to remove the paragraph. It can be rephrased to something more inline with:
For a comparison of the SVC with other classifiers see: | |
:ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. | |
For an example on how to enable probability estimates for SVC, see: | |
:ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. |
sklearn/svm/_base.py
Outdated
@@ -183,6 +183,9 @@ def fit(self, X, y, sample_weight=None): | |||
|
|||
If X is a dense array, then the other methods will not support sparse | |||
matrices as input. | |||
|
|||
For an example of handling weighed samples with :class:`SVC`s, please see: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rendering is currently broken, let's see if this fixes the issue:
For an example of handling weighed samples with :class:`SVC`s, please see: | |
For an example of handling weighed samples with :class:`svm.SVC`s, please see: |
I see things a bit differently: I believe examples should be linked from where they are most useful and directly relevant to the context. This way they provide immediate value to users. Creating another condensed version of the Sphinx Gallery as just a collection of links might not serve the same purpose effectively. The author of this PR has implemented just what issue #30621 was asking for. There is no gain in calling that into question now, unless you want to close that issue and open a new issue and take care of it. |
No worries @simarssidhu, once you have started force pushing it might be difficult to get out of that. Just keep this in mind for future PRs. |
I am definitely not blaming the author of this PR. I want to clarify as well that #30621 asks for adding references to examples in the relevant sections, without clearly stating what those relevant sections are.
I'm not questioning the issue, just sharing my opinion, which I hope you don't take personally. To be clear I am not against adding links to the examples, so no need to close the issue. I’ve simply been advocating for a consistent approach. In particular I personally would discourage:
Instead, as suggested in my original comment, I suggest:
I understand the perspective, and I agree they should be linked from where they are relevant and helpful. However, I don't know in which place they would be more useful, as there is a trade-off to consider: examples in the relevant places may be harder to find, and a more centralized and consistent location (like the main paragraph, where they would be the first thing to read) could make the documentation easier to navigate for users, at the risk of reducing relevancy. In any case I insist that this is only my opinion, and as it has been disregarded before, I decided to step back from reviewing related PRs. |
No hard feelings, @ArturoAmorQ, I understand that we have different opinions and I appreciate that you have shared yours. I totally respect your decision and won't ping you on related issues any more. |
The PR looks pretty good now, @simarssidhu! Note that by linking to the example from BaseLibSVM, we are showing it in the docs for several other SVM based classifiers as well, which in my eyes is a gain. Would you like to have a look, @adrinjalali? |
Putting my comment about placement aside, I still expect my other comments to be addressed. The render is still broken and I still think the wording "For a comparison of the SVC with other classifiers" does not reflect the real intention of the example.
I would rather ping somebody more neutral on the subject, such as @lucyleeow. |
…larity, and fixed rendering
Hi @StefanieSenger and @ArturoAmorQ , Sorry, I've been travelling the past few days haha 😅 Thanks so much for reviewing my work! I've gone ahead and made the suggested changes, and believe it's sufficient according to the issue (#30621). I'll address the merge conflict issues tonight. I believe all I have to do is rebase to the Thanks, |
It's better to merge the main branch into your branch directly. This way, you can resolve the merge conflicts by keeping both main's and your branche's changes. |
Thanks for the discussion. I have to admit that I have had similar thoughts to @ArturoAmorQ regarding this issue, but did not feel that it was necessary at the time to voice my opinion. Since I'm being pinged I have to say that I don't love adding links to examples to the In this case, there are quite a few SVC examples (though some are not very relevant, For this particular example, I would say adding a link to the What I think may be a better idea is to improve the examples list at the end of all API pages. E.g., the I don't have a good solution to fixing this though; we could order them from most relevant to least (maybe something vaguely akin to the great recommender system you added to Sphinx-Gallery: sphinx-gallery/sphinx-gallery#1125), exclude some, or group them into 2 sections (examples completely about |
Hi @StefanieSenger. perfect, thanks so much! That seemed to fix the issue :) Hi @lucyleeow, thank you for your input! I must admit, it's a bit above my understanding at the moment, as this is my first commit to scikit-learn. Hi everyone, do you think this problem should be addressed in a newer, separate issue? For this one, I believe I've focused on fulfilling the requirements outlined in #30621. In the meantime, I'll move onto another issue, until I gain more clarity on how to proceed here. Thanks, |
Hi @simarssidhu, thanks for your further work and for your patience. I'm sorry this discussion was led on your PR; it should have been led on the issue instead and unfortunately, I didn't see it coming at all. I hope you're not tired of contributing yet. There is another meta-issue you could try (#22827) for your first contribution, in case you wonder if weather to continue adding links to the examples or not. I think it's best to close this issue, because lamentably maintainers disagree on it. |
A new PR can potentially be opened for this task in the future. I believe it is not the contributor's responsibility to propose further solutions until maintainers agree on a broader path forward. Let's await further guidance from maintainers and concentrate on other tasks in the meantime. |
Thanks so much for you help @StefanieSenger! I'll move onto (#22827) for my first contribution :D |
Changes
LinearSVC
andSVC
comaprison
tocomparison
Purpose:
Related Issues: