Skip to content

Instantly share code, notes, and snippets.

@ashunigion
Last active January 26, 2019 08:03
Show Gist options
  • Save ashunigion/b3d94279e037aaf5942cd0c72a97259f to your computer and use it in GitHub Desktop.
Save ashunigion/b3d94279e037aaf5942cd0c72a97259f to your computer and use it in GitHub Desktop.
# 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