(features, classes, labels)
return X, y
Format the labelled data in an X features matrix and a y labels vector, so
    that it can be used for training an ML model.

    KV WRL 2019

    Arguments:
    -----------
    features: dict
        contains the features for each labelled pixel
    classes: list of str
        names of the classes
    labels: list of int
        int value associated with each class (in the same order as classes)
                
    Returns:
    -----------
    X: np.array
        matrix features along the columns and pixels along the rows
    y: np.array
        vector with the labels corresponding to each row of X
Format the labelled data in an X features matrix and a y labels vector, so
    that it can be used for training an ML model.
Format the labelled data in an X features matrix and a y labels vector so that it can be used for training an ML model .
def format_training_data(features, classes, labels):
    """
    Format the labelled data in an X features matrix and a y labels vector, so
    that it can be used for training an ML model.

    KV WRL 2019

    Arguments:
    -----------
    features: dict
        contains the features for each labelled pixel
    classes: list of str
        names of the classes
    labels: list of int
        int value associated with each class (in the same order as classes)
                
    Returns:
    -----------
    X: np.array
        matrix features along the columns and pixels along the rows
    y: np.array
        vector with the labels corresponding to each row of X
    
    """
    
    # initialize X and y
    X = np.nan*np.ones((1,features[classes[0]].shape[1]))
    y = np.nan*np.ones((1,1))
    # append row of features to X and corresponding label to y 
    for i,key in enumerate(classes):
        y = np.append(y, labels[i]*np.ones((features[key].shape[0],1)), axis=0)
        X = np.append(X, features[key], axis=0)
    # remove first row
    X = X[1:,:]; y = y[1:]
    # replace nans with something close to 0
    # training algotihms cannot handle nans
    X[np.isnan(X)] = 1e-9 
    
    return X, y
def format_training_data ( features , classes , labels ) : # initialize X and y X = np . nan * np . ones ( ( 1 , features [ classes [ 0 ] ] . shape [ 1 ] ) ) y = np . nan * np . ones ( ( 1 , 1 ) ) # append row of features to X and corresponding label to y  for i , key in enumerate ( classes ) : y = np . append ( y , labels [ i ] * np . ones ( ( features [ key ] . shape [ 0 ] , 1 ) ) , axis = 0 ) X = np . append ( X , features [ key ] , axis = 0 ) # remove first row X = X [ 1 : , : ] y = y [ 1 : ] # replace nans with something close to 0 # training algotihms cannot handle nans X [ np . isnan ( X ) ] = 1e-9 return X , y