Skip to content

Instantly share code, notes, and snippets.

@singhrahuldps
Last active June 1, 2019 05:50
Show Gist options
  • Select an option

  • Save singhrahuldps/a49a64fadff553ba34fec8d0b71cc2da to your computer and use it in GitHub Desktop.

Select an option

Save singhrahuldps/a49a64fadff553ba34fec8d0b71cc2da to your computer and use it in GitHub Desktop.
# Making life easier with fast.ai
# required library -> fastai (https://github.com/fastai/fastai/)
from fastai.collab import *
from fastai.tabular import *
# loading the dataframe
ratings = pd.read_csv('ratings.csv')
# creating data object
data = CollabDataBunch.from_df(ratings, seed=42, valid_pct=0.1)
# creating a learner object used for training and testing
learn = collab_learner(data, n_factors=40, y_range=[0,11])
# training method using the 1Cycle training policy (https://sgugger.github.io/the-1cycle-policy.html)
learn.fit_one_cycle(5, 5e-3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment