<s> '''<STR_LIT>''' <EOL> from pyvision . types . Point import Point <EOL> from pyvision . vector import SVM <EOL> from pyvision . vector . RidgeRegression import KernelRidgeRegression <EOL> class SVMLocator : <EOL> def __init__ ( self , svm_type = SVM . TYPE_NU_SVR , ** kwargs ) : <EOL> self . x_svm = SVM . SVM ( svm_type = svm_type , ** kwargs ) <EOL> self . y_svm = SVM . SVM ( svm_type = svm_type , ** kwargs ) <EOL> self . x_sum = <NUM_LIT:0.0> <EOL> self . y_sum = <NUM_LIT:0.0> <EOL> self . point_count = <NUM_LIT:0> <EOL> def addTraining ( self , image , location ) : <EOL> '''<STR_LIT>''' <EOL> self . x_svm . addTraining ( location . X ( ) , image ) <EOL> self . y_svm . addTraining ( location . Y ( ) , image ) <EOL> self . x_sum += location . X ( ) <EOL> self . y_sum += location . Y ( ) <EOL> self . point_count += <NUM_LIT:1> <EOL> def train ( self , ** kwargs ) : <EOL> self . x_svm . train ( ** kwargs ) <EOL> self . y_svm . train ( ** kwargs ) <EOL> cx = self . x_sum / self . point_count <EOL> cy = self . y_sum / self . point_count <EOL> self . mean = Point ( cx , cy ) <EOL> def predict ( self , image ) : <EOL> x = self . x_svm . predict ( image ) <EOL> y = self . y_svm . predict ( image ) <EOL> return Point ( x , y ) <EOL> class KRRLocator : <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . x_krr = KernelRidgeRegression ( ** kwargs ) <EOL> self . y_krr = KernelRidgeRegression ( ** kwargs ) <EOL> self . x_sum = <NUM_LIT:0.0> <EOL> self . y_sum = <NUM_LIT:0.0> <EOL> self . point_count = <NUM_LIT:0> <EOL> def addTraining ( self , image , location ) : <EOL> '''<STR_LIT>''' <EOL> self . x_krr . addTraining ( location . X ( ) , image ) <EOL> self . y_krr . addTraining ( location . Y ( ) , image ) <EOL> self . x_sum += location . X ( ) <EOL> self . y_sum += location . Y ( ) <EOL> self . point_count += <NUM_LIT:1> <EOL> def train ( self , ** kwargs ) : <EOL> self . x_krr . train ( ** kwargs ) <EOL> self . y_krr . train ( ** kwargs ) <EOL> cx = self . x_sum / self . point_count <EOL> cy = self . y_sum / self . point_count <EOL> self . mean = Point ( cx , cy ) <EOL> def predict ( self , image ) : <EOL> x = self . x_krr . predict ( image ) <EOL> y = self . y_krr . predict ( image ) <EOL> return Point ( x , y ) </s>
