Search code examples
python-2.7scikit-learnsvmsvc

What is the standalone SVC line in sklearn.SVC doing?


In SKLEARN for SVC, there is a part of the code that I don't quite understand its purpose. I understand the idea of passing parameters to SVC when creating a classifier. But the line I am curious about isn't creating a classifier. It is just "SVC(....)" on a standalone line. I am not sure if it is just there as an example of how to format parameters in an example... or if it is actually modifying the classifier that was just created... or something else.

Every time I have seen the creation of a classifier, it has the form:

>>> clf = SVC(...)

I have tried searching for "standalone SVC" and things like this, to no avail.

# This is taken straight from sklearn.SVC
# https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html

import numpy as np
X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
y = np.array([1, 1, 2, 2])
from sklearn.svm import SVC
clf = SVC(gamma='auto')
clf.fit(X, y) 

# This is the line I am questioning

SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
    decision_function_shape='ovr', degree=3, gamma='auto', kernel='rbf',
    max_iter=-1, probability=False, random_state=None, shrinking=True,
    tol=0.001, verbose=False)

print(clf.predict([[-0.8, -1]]))

I believe this is just an example, but if it is actually serving a purpose, I am at a loss. Thanks!


Solution

  • The line you are questioning is an output line and not a code. On the right above corner there is also a button: 'Hide the prompts and output', try to hit this one and you will understand what I mean.

    This line is just a support for you, that you can see how the SVC classifier is adjusted right now in your code. It is an overview