public SVM < T > train ( T [ ] x , int [ ] y , double [ ] weight ) { SVM < T > svm = null ; if ( k == 2 ) { svm = new SVM <> ( kernel , Cp , Cn ) ; } else { if ( this . weight == null ) { svm = new SVM <> ( kernel , Cp , k , strategy ) ; } else { svm = new SVM <> ( kernel , Cp , this . weight , strategy ) ; } } svm . setTolerance ( tol ) ; for ( int i = 1 ; i <= epochs ; i ++ ) { svm . learn ( x , y , weight ) ; } svm . finish ( ) ; return svm ; }
Learns a SVM classifier with given training data .