def test_precision_recall_f1_score():
 y_real = np.array([['a', 'b', 'c'], ['a', 'b', 'e', 'f', 'g'], ['a', 'b']])
 y_pred = np.array([['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['e', 'f']])
 (p, r, f) = precision_recall_fscore(y_real, y_pred)
 assert_array_almost_equal(p, [1, 0.4, 0], 2)
 assert_array_almost_equal(r, [1.0, 0.5, 0], 2)
 assert_array_almost_equal(f, [1.0, 0.44, 0], 2)
 ps = precision_score(y_real, y_pred)
 assert_array_almost_equal(ps, 0.4666, 2)
 rs = recall_score(y_real, y_pred)
 assert_array_almost_equal(rs, 0.5, 2)
 fs = f1_score(y_real, y_pred)
 assert_array_almost_equal(fs, 0.48, 2)

def test_precision_recall_f1_score ( ) : y_real = np . array ( [ [ 'a' , 'b' , 'c' ] , [ 'a' , 'b' , 'e' , 'f' , 'g' ] , [ 'a' , 'b' ] ] ) y_pred = np . array ( [ [ 'a' , 'b' , 'c' ] , [ 'a' , 'b' , 'c' , 'd' ] , [ 'e' , 'f' ] ] ) ( p , r , f ) = precision_recall_fscore ( y_real , y_pred ) assert_array_almost_equal ( p , [ 1 , 0.4 , 0 ] , 2 ) assert_array_almost_equal ( r , [ 1.0 , 0.5 , 0 ] , 2 ) assert_array_almost_equal ( f , [ 1.0 , 0.44 , 0 ] , 2 ) ps = precision_score ( y_real , y_pred ) assert_array_almost_equal ( ps , 0.4666 , 2 ) rs = recall_score ( y_real , y_pred ) assert_array_almost_equal ( rs , 0.5 , 2 ) fs = f1_score ( y_real , y_pred ) assert_array_almost_equal ( fs , 0.48 , 2 )
test precision recall and f1 score .