Created
June 1, 2019 04:51
-
-
Save singhrahuldps/5830ac62070d918929c5918e1642d469 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
# splits ratings dataframe to training and validation dataframes | |
def get_data(ratings, valid_pct:float = 0.2): | |
# shuffle the indexes | |
ln = random.sample(range(0, len(ratings)), len(ratings)) | |
# split based on the given validation set percentage | |
part = int(len(ln)*valid_pct) | |
valid_index = ln[0:part] | |
train_index = ln[part:] | |
valid = ratings.iloc[valid_index] | |
train = ratings.iloc[train_index] | |
return [train,valid] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment