Last active
January 26, 2019 08:03
-
-
Save ashunigion/b3d94279e037aaf5942cd0c72a97259f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the following snippet was provided as starter code by UCSD for the course | |
# Machine Learning Fundamentals on edX | |
def rand_prototypes(M): | |
""" | |
Returns M randomly samples data points and corresponding labels. | |
Parameters: | |
M (int): number of data points to be sampled | |
Returns: | |
train_data (numpy array) : the random subset of dataset | |
train_labels (numpy array) : labels of randomly selected dataset | |
""" | |
indices = np.random.choice( len(train_labels) , M, replace=False) | |
return train_data[indices,:], train_labels[indices] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment