protected void sparsify ( ) { final int N = vecs . size ( ) ; int accSize = accelCache == null ? 0 : accelCache . size ( ) / N ; int svCount = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( alphas [ i ] != 0 ) //Its a support vector { ListUtils . swap ( vecs , svCount , i ) ; if ( accelCache != null ) for ( int j = i * accSize ; j < ( i + 1 ) * accSize ; j ++ ) ListUtils . swap ( accelCache , svCount * accSize + j - i * accSize , j ) ; alphas [ svCount ++ ] = alphas [ i ] ; } vecs = new ArrayList < Vec > ( vecs . subList ( 0 , svCount ) ) ; alphas = Arrays . copyOfRange ( alphas , 0 , svCount ) ; }
Sparsifies the SVM by removing the vectors with &alpha ; = 0 from the dataset .