scikit learn SVM, how to save/load support vectors?
Question: using python scikit svm, after running clf.fit(X, Y), you get your support
vectors. could I load these support vectors directly (passing them as
paramter) when instantiate a svm.SVC object? which means I do not need to
running fit() method each time to do predication


Answer: From the scikit manual: <http://scikit-
learn.org/stable/modules/model_persistence.html>

1.2.4 Model persistence It is possible to save a model in the scikit by using
Python’s built-in persistence model, namely pickle.

    
    
    >>> from sklearn import svm
    >>> from sklearn import datasets
    >>> clf = svm.SVC()
    >>> iris = datasets.load_iris()
    >>> X, y = iris.data, iris.target
    >>> clf.fit(X, y)
    SVC(kernel=’rbf’, C=1.0, probability=False, degree=3, coef0=0.0, eps=0.001,
    cache_size=100.0, shrinking=True, gamma=0.00666666666667)
    >>> import pickle
    >>> s = pickle.dumps(clf)
    >>> clf2 = pickle.loads(s)
    >>> clf2.predict(X[0])
    array([ 0.])
    >>> y[0]
    0
    

In the specific case of the scikit, it may be more interesting to use joblib’s
replacement of pickle, which is more efficient on big data, but can only
pickle to the disk and not to a string:

    
    
    >>> from sklearn.externals import joblib
    >>> joblib.dump(clf, ’filename.pkl’)
    

