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

Skip to content

Added examples to docstrings of LinearSVC and LinearSVR #9375

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

Merged
merged 1 commit into from
Jul 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions sklearn/svm/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ class LinearSVC(BaseEstimator, LinearClassifierMixin,
intercept_ : array, shape = [1] if n_classes == 2 else [n_classes]
Constants in decision function.

Examples
--------
>>> 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.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)
>>> print(clf.coef_)
[[ 0.08551385 0.39414796 0.49847831 0.37513797]]
>>> print(clf.intercept_)
[ 0.28418066]
>>> print(clf.predict([[0, 0, 0, 0]]))
[1]

Notes
-----
The underlying C implementation uses a random number generator to
Expand Down Expand Up @@ -302,6 +320,22 @@ class LinearSVR(LinearModel, RegressorMixin):
intercept_ : array, shape = [1] if n_classes == 2 else [n_classes]
Constants in decision function.

Examples
--------
>>> 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.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)
>>> print(regr.coef_)
[ 16.35750999 26.91499923 42.30652207 60.47843124]
>>> print(regr.intercept_)
[-4.29756543]
>>> print(regr.predict([[0, 0, 0, 0]]))
[-4.29756543]

See also
--------
Expand Down