diff --git a/doc/modules/model_evaluation.rst b/doc/modules/model_evaluation.rst index 8c4874edf84c1..6c75998ba6e59 100644 --- a/doc/modules/model_evaluation.rst +++ b/doc/modules/model_evaluation.rst @@ -98,9 +98,9 @@ Usage examples: >>> from sklearn.model_selection import cross_val_score >>> iris = datasets.load_iris() >>> X, y = iris.data, iris.target - >>> clf = svm.SVC(gamma='scale', probability=True, random_state=0) - >>> cross_val_score(clf, X, y, scoring='neg_log_loss') # doctest: +ELLIPSIS - array([-0.10..., -0.16..., -0.07...]) + >>> clf = svm.SVC(gamma='scale', random_state=0) + >>> cross_val_score(clf, X, y, scoring='recall_macro') # doctest: +ELLIPSIS + array([0.980..., 0.960..., 0.979...]) >>> model = svm.SVC() >>> cross_val_score(model, X, y, scoring='wrong_choice') Traceback (most recent call last): diff --git a/sklearn/svm/classes.py b/sklearn/svm/classes.py index db9360e64fb4f..99d07b7d51fce 100644 --- a/sklearn/svm/classes.py +++ b/sklearn/svm/classes.py @@ -116,16 +116,15 @@ class LinearSVC(BaseEstimator, LinearClassifierMixin, >>> from sklearn.svm import LinearSVC >>> from sklearn.datasets import make_classification >>> X, y = make_classification(n_features=4, random_state=0) - >>> clf = LinearSVC(random_state=0) + >>> clf = LinearSVC(random_state=0, tol=1e-5) >>> clf.fit(X, y) LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True, intercept_scaling=1, loss='squared_hinge', max_iter=1000, - multi_class='ovr', penalty='l2', random_state=0, tol=0.0001, - verbose=0) + multi_class='ovr', penalty='l2', random_state=0, tol=1e-05, verbose=0) >>> print(clf.coef_) - [[0.08551385 0.39414796 0.49847831 0.37513797]] + [[0.085... 0.394... 0.498... 0.375...]] >>> print(clf.intercept_) - [0.28418066] + [0.284...] >>> print(clf.predict([[0, 0, 0, 0]])) [1] @@ -327,17 +326,17 @@ class LinearSVR(LinearModel, RegressorMixin): >>> from sklearn.svm import LinearSVR >>> from sklearn.datasets import make_regression >>> X, y = make_regression(n_features=4, random_state=0) - >>> regr = LinearSVR(random_state=0) + >>> regr = LinearSVR(random_state=0, tol=1e-5) >>> regr.fit(X, y) LinearSVR(C=1.0, dual=True, epsilon=0.0, fit_intercept=True, intercept_scaling=1.0, loss='epsilon_insensitive', max_iter=1000, - random_state=0, tol=0.0001, verbose=0) + random_state=0, tol=1e-05, verbose=0) >>> print(regr.coef_) - [16.35750999 26.91499923 42.30652207 60.47843124] + [16.35... 26.91... 42.30... 60.47...] >>> print(regr.intercept_) - [-4.29756543] + [-4.29...] >>> print(regr.predict([[0, 0, 0, 0]])) - [-4.29756543] + [-4.29...] See also --------