def _one_vs_one_coef(dual_coef, n_support, support_vectors):
 n_class = (dual_coef.shape[0] + 1)
 coef = []
 sv_locs = np.cumsum(np.hstack([[0], n_support]))
 for class1 in range(n_class):
  sv1 = support_vectors[sv_locs[class1]:sv_locs[(class1 + 1)], :]
  for class2 in range((class1 + 1), n_class):
   sv2 = support_vectors[sv_locs[class2]:sv_locs[(class2 + 1)], :]
   alpha1 = dual_coef[(class2 - 1), sv_locs[class1]:sv_locs[(class1 + 1)]]
   alpha2 = dual_coef[class1, sv_locs[class2]:sv_locs[(class2 + 1)]]
   coef.append((safe_sparse_dot(alpha1, sv1) + safe_sparse_dot(alpha2, sv2)))
 return coef

def _one_vs_one_coef ( dual_coef , n_support , support_vectors ) : n_class = ( dual_coef . shape [ 0 ] + 1 ) coef = [ ] sv_locs = np . cumsum ( np . hstack ( [ [ 0 ] , n_support ] ) ) for class1 in range ( n_class ) : sv1 = support_vectors [ sv_locs [ class1 ] : sv_locs [ ( class1 + 1 ) ] , : ] for class2 in range ( ( class1 + 1 ) , n_class ) : sv2 = support_vectors [ sv_locs [ class2 ] : sv_locs [ ( class2 + 1 ) ] , : ] alpha1 = dual_coef [ ( class2 - 1 ) , sv_locs [ class1 ] : sv_locs [ ( class1 + 1 ) ] ] alpha2 = dual_coef [ class1 , sv_locs [ class2 ] : sv_locs [ ( class2 + 1 ) ] ] coef . append ( ( safe_sparse_dot ( alpha1 , sv1 ) + safe_sparse_dot ( alpha2 , sv2 ) ) ) return coef
generate primal coefficients from dual coefficients for the one-vs-one multi class libsvm in the case of a linear kernel .