program pysvmpredict
    version 16
    syntax, predict(name)

    // get the feature variables stored by pysvm
	local features = e(features)
	
    // call the Python function
    python: dopredict("`features'", "`predict'")
end

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

def dopredict(features, predict):
    # access the trained model from the __main__ global 
    # namespace
    svm_clf = __main__.svm_clf

    X = np.array(Data.get(features))
    y_pred = svm_clf.predict(X)

    Data.addVarByte(predict)
    Data.store(predict, None, y_pred)

end