#NEWLINE# def test_cohenskappa_weights( ) : #NEWLINE# #INDENT# np . random . seed ( 9743678 ) #NEWLINE# table = ( np . random . randint ( 0 , 10 , size = ( 5 , 5 ) ) + ( 5 * np . eye ( 5 ) ) ) #NEWLINE# mat = np . array ( [ [ 1 , 1 , 1 , 0 , 0 ] , [ 0 , 0 , 0 , 1 , 1 ] ] ) #NEWLINE# table_agg = np . dot ( np . dot ( mat , table ) , mat . T ) #NEWLINE# res1 = cohens_kappa ( table , weights = ( np . arange ( 5 ) > 2 ) , wt = 'linear' ) #NEWLINE# res2 = cohens_kappa ( table_agg , weights = np . arange ( 2 ) , wt = 'linear' ) #NEWLINE# assert_almost_equal ( res1 . kappa , res2 . kappa , decimal = 14 ) #NEWLINE# assert_almost_equal ( res1 . var_kappa , table . var_kappa , decimal = 14 ) #NEWLINE# res1 = cohens_kappa ( table , weights = ( 2 * np . arange ( 5 ) ) , wt = 'linear' ) #NEWLINE# res2 = cohens_kappa ( table , weights = ( 2 * np . arange ( 5 ) ) , wt = 'toeplitz' ) #NEWLINE# res3 = cohens_kappa ( table , weights = res1 . weights [ 0 ] , wt = 'toeplitz' ) #NEWLINE# res4 = cohens_kappa ( table , weights = res1 . weights ) #NEWLINE# assert_almost_equal ( res1 . kappa , res2 . kappa , decimal = 14 ) #NEWLINE# assert_almost_equal ( res1 . var_kappa , res2 . var_kappa , decimal = 14 ) #NEWLINE# assert_almost_equal ( res1 . kappa , res3 . kappa , decimal = 14 ) #NEWLINE# assert_almost_equal ( res1 . var_kappa , res3 . var_kappa , decimal = 14 ) #NEWLINE# assert_almost_equal ( res1 . kappa , res4 . kappa , decimal = 14 ) #NEWLINE# assert_almost_equal ( res1 . var_kappa , res4 . var_kappa , decimal = 14 ) #NEWLINE# res1 = cohens_kappa ( table , weights = ( 5 * ( np . arange ( 5 ) ** 2 ) ) , wt = 'toeplitz' ) #NEWLINE# res2 = cohens_kappa ( table , weights = ( 5 * np . arange ( 5 ) ) , wt = 'quadratic' ) #NEWLINE# assert_almost_equal ( res1 . kappa , res2 . kappa , decimal = 14 ) #NEWLINE# assert_almost_equal ( res1 . var_kappa , res2 . var_kappa , decimal = 14 )