util.py
def list2matrix(ylist):
  """
  Rewrites a list-of-lists of labels for the multilabel case into a
  0-1 label matrix. The matrix is a numpy array (dense data type),
  but fairly sparse in practice.
  
  Params:
    ylist - a list of lists of integer labels for multilabel classification
  
  Returns:
    a 0-1 numpy array of size (# instances) x (# classes)
  """
  y = np.zeros((NROW_TRAIN, NLABELS))
  for k in range(len(ylist)):
    yl = ylist[k]
    for l in yl:
      y[k, l-1] = 1  
  return y

  Rewrites a list-of-lists of labels for the multilabel case into a
  0-1 label matrix. The matrix is a numpy array (dense data type),
  but fairly sparse in practice.
  
  Params:
    ylist - a list of lists of integer labels for multilabel classification
  
  Returns:
    a 0-1 numpy array of size (# instances) x (# classes)
  
Rewrites a list-of-lists of labels for the multilabel case into a
0-1 label matrix. The matrix is a numpy array (dense data type),
but fairly sparse in practice.

a list of lists of integer labels for multilabel classification

a 0-1 numpy array of size (# instances) x (# classes)
Rewrites a list - of - lists of labels for the multilabel case into a 0 - 1 label matrix . The matrix is a numpy array ( dense data type ) but fairly sparse in practice . a list of lists of integer labels for multilabel classification a 0 - 1 numpy array of size ( # instances ) x ( # classes )
def list2matrix(ylist):
  y = np.zeros((NROW_TRAIN, NLABELS))
  for k in range(len(ylist)):
    yl = ylist[k]
    for l in yl:
      y[k, l-1] = 1  
  return y
def list2matrix ( ylist ) : y = np . zeros ( ( NROW_TRAIN , NLABELS ) ) for k in range ( len ( ylist ) ) : yl = ylist [ k ] for l in yl : y [ k , l - 1 ] = 1 return y
Rewrites a list-of-lists of labels for the multilabel case into a
0-1 label matrix.
Rewrites a list - of - lists of labels for the multilabel case into a 0 - 1 label matrix .
"""
  Rewrites a list-of-lists of labels for the multilabel case into a
  0-1 label matrix. The matrix is a numpy array (dense data type),
  but fairly sparse in practice.
  
  Params:
    ylist - a list of lists of integer labels for multilabel classification
  
  Returns:
    a 0-1 numpy array of size (# instances) x (# classes)
  """
ylist