program pysvm, eclass
    version 16
    syntax varlist [if] [in]
 
    marksample touse
    gettoken label feature : varlist

    //call the Python function
    python: dosvm("`label'", "`feature'", "`touse'")
	
	// store the feature variable names so that 
	// they can be retrieved in the prediction command
    ereturn local features `feature'
end

python:
from sfi import Data
import numpy as np
from sklearn.svm import SVC
import __main__

def dosvm(label, features, touse):
    X = np.array(Data.get(features, None, touse))
    y = np.array(Data.get(label, None, touse))

    svm_clf = SVC(gamma='auto', random_state=16)
    svm_clf.fit(X, y)

    '''
    add the classification model object into
    the __main__ namespace so that it can be 
    accessed by other ado programs
    '''
    __main__.svm_clf = svm_clf

end