def aggregate_raters(data, n_cat=None):
 data = np.asarray(data)
 n_rows = data.shape[0]
 if (n_cat is None):
  (cat_uni, cat_int) = np.unique(data.ravel(), return_inverse=True)
  n_cat = len(cat_uni)
  data_ = cat_int.reshape(data.shape)
 else:
  cat_uni = np.arange(n_cat)
  data_ = data
 tt = np.zeros((n_rows, n_cat), int)
 for (idx, row) in enumerate(data_):
  ro = np.bincount(row)
  tt[idx, :len(ro)] = ro
 return (tt, cat_uni)

def aggregate_raters ( data , n_cat = None ) : data = np . asarray ( data ) n_rows = data . shape [ 0 ] if ( n_cat is None ) : ( cat_uni , cat_int ) = np . unique ( data . ravel ( ) , return_inverse = True ) n_cat = len ( cat_uni ) data_ = cat_int . reshape ( data . shape ) else : cat_uni = np . arange ( n_cat ) data_ = data tt = np . zeros ( ( n_rows , n_cat ) , int ) for ( idx , row ) in enumerate ( data_ ) : ro = np . bincount ( row ) tt [ idx , : len ( ro ) ] = ro return ( tt , cat_uni )
convert raw data with shape to brings data into correct format for fleiss_kappa bincount will raise exception if data cannot be converted to integer .