From c7f9084fa6b55af7c7cc3bf9087d23f07cb92536 Mon Sep 17 00:00:00 2001 From: Simarjot Sidhu Date: Mon, 20 Jan 2025 22:25:13 -0500 Subject: [PATCH 1/7] Added reference to weighted samples example in SVM docs --- sklearn/svm/_classes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index 0eb49a8c0832c..e314f8d412a66 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -843,6 +843,9 @@ class SVC(BaseSVC): >>> print(clf.predict([[-0.8, -1]])) [1] + For an example of handling weighed samples with :class:`SVC`s, please see: + :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` + For a comaprison of the SVC with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """ From 0f37ec7fb9cfb5a3018b82603720117af42248a1 Mon Sep 17 00:00:00 2001 From: Simarjot Sidhu Date: Mon, 20 Jan 2025 22:25:36 -0500 Subject: [PATCH 2/7] Minor typo fix in comments --- sklearn/svm/_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index e314f8d412a66..11528f7838ed2 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -846,7 +846,7 @@ class SVC(BaseSVC): For an example of handling weighed samples with :class:`SVC`s, please see: :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` - For a comaprison of the SVC with other classifiers see: + For a comparison of the SVC with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """ From a9652571804d69fd03c621f9761f8877cc8a7e16 Mon Sep 17 00:00:00 2001 From: Simarjot Sidhu Date: Tue, 21 Jan 2025 21:44:29 -0500 Subject: [PATCH 3/7] Added reference to weighted samples example in SVM docs --- sklearn/svm/_classes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index 0eb49a8c0832c..e314f8d412a66 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -843,6 +843,9 @@ class SVC(BaseSVC): >>> print(clf.predict([[-0.8, -1]])) [1] + For an example of handling weighed samples with :class:`SVC`s, please see: + :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` + For a comaprison of the SVC with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """ From 5a804586d0df87fdfebcca3771bda0ada56eab77 Mon Sep 17 00:00:00 2001 From: Simarjot Sidhu Date: Tue, 21 Jan 2025 21:44:29 -0500 Subject: [PATCH 4/7] Minor typo fix in comments --- sklearn/svm/_classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index e314f8d412a66..11528f7838ed2 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -846,7 +846,7 @@ class SVC(BaseSVC): For an example of handling weighed samples with :class:`SVC`s, please see: :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` - For a comaprison of the SVC with other classifiers see: + For a comparison of the SVC with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """ From 1188b15814d9b69f9f547860f62f452fa58c6a5e Mon Sep 17 00:00:00 2001 From: Simarjot Sidhu Date: Tue, 21 Jan 2025 21:57:01 -0500 Subject: [PATCH 5/7] Moved reference to sample_weight in BaseLibSVM.fit() --- sklearn/svm/_base.py | 3 +++ sklearn/svm/_classes.py | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/svm/_base.py b/sklearn/svm/_base.py index f5b35f39a7daf..95108e639df59 100644 --- a/sklearn/svm/_base.py +++ b/sklearn/svm/_base.py @@ -171,6 +171,9 @@ def fit(self, X, y, sample_weight=None): Per-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points. + For an example of handling weighed samples with :class:`SVC`s, please see: + :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` + Returns ------- self : object diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index 11528f7838ed2..8f243937bccf1 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -843,9 +843,6 @@ class SVC(BaseSVC): >>> print(clf.predict([[-0.8, -1]])) [1] - For an example of handling weighed samples with :class:`SVC`s, please see: - :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` - For a comparison of the SVC with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """ From c0c0449c8d9a3aab3122c02fc83233b052678b39 Mon Sep 17 00:00:00 2001 From: Simarjot Sidhu Date: Tue, 21 Jan 2025 22:30:49 -0500 Subject: [PATCH 6/7] Moved reference to 'Notes' section to comply with test requirements (#30676) --- sklearn/svm/_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/svm/_base.py b/sklearn/svm/_base.py index 95108e639df59..f802512fe9163 100644 --- a/sklearn/svm/_base.py +++ b/sklearn/svm/_base.py @@ -171,9 +171,6 @@ def fit(self, X, y, sample_weight=None): Per-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points. - For an example of handling weighed samples with :class:`SVC`s, please see: - :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` - Returns ------- self : object @@ -186,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: + :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` """ rnd = check_random_state(self.random_state) From ecb689769929389fb9d17051f4139df1dd347372 Mon Sep 17 00:00:00 2001 From: Simarjot Sidhu Date: Mon, 27 Jan 2025 01:33:28 -0500 Subject: [PATCH 7/7] Addressed comments in PR (#30676), changed comments for clarity, and fixed rendering --- sklearn/gaussian_process/_gpc.py | 2 +- sklearn/linear_model/_logistic.py | 2 +- sklearn/svm/_base.py | 2 +- sklearn/svm/_classes.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/gaussian_process/_gpc.py b/sklearn/gaussian_process/_gpc.py index ff094e4d5f4fd..b923e09bcd8eb 100644 --- a/sklearn/gaussian_process/_gpc.py +++ b/sklearn/gaussian_process/_gpc.py @@ -642,7 +642,7 @@ def optimizer(obj_func, initial_theta, bounds): array([[0.83548752, 0.03228706, 0.13222543], [0.79064206, 0.06525643, 0.14410151]]) - For a comaprison of the GaussianProcessClassifier with other classifiers see: + For a comparison of the GaussianProcessClassifier with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """ diff --git a/sklearn/linear_model/_logistic.py b/sklearn/linear_model/_logistic.py index 291c3972eb3e5..f001ad6dae841 100644 --- a/sklearn/linear_model/_logistic.py +++ b/sklearn/linear_model/_logistic.py @@ -1096,7 +1096,7 @@ class LogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstimator): >>> clf.score(X, y) 0.97... - For a comaprison of the LogisticRegression with other classifiers see: + For a comparison of the LogisticRegression with other classifiers see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """ diff --git a/sklearn/svm/_base.py b/sklearn/svm/_base.py index f802512fe9163..2e7dd3d6114b6 100644 --- a/sklearn/svm/_base.py +++ b/sklearn/svm/_base.py @@ -184,7 +184,7 @@ 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: + For an example of handling weighed samples with :class:`svm.SVC`s, please see: :ref:`sphx_glr_auto_examples_svm_plot_weighted_samples.py` """ rnd = check_random_state(self.random_state) diff --git a/sklearn/svm/_classes.py b/sklearn/svm/_classes.py index 8f243937bccf1..cda34bbf7d093 100644 --- a/sklearn/svm/_classes.py +++ b/sklearn/svm/_classes.py @@ -843,7 +843,7 @@ class SVC(BaseSVC): >>> print(clf.predict([[-0.8, -1]])) [1] - For a comparison of the SVC with other classifiers see: + For an example on how to enable probability estimates for SVC, see: :ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`. """