Skip to content

Instantly share code, notes, and snippets.

@Ben-Karr
Created September 25, 2022 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ben-Karr/ee9ef0283c910e3e8db23e4e2667c2c5 to your computer and use it in GitHub Desktop.
Save Ben-Karr/ee9ef0283c910e3e8db23e4e2667c2c5 to your computer and use it in GitHub Desktop.
Fastai minimal Quick-Start-Code: Tabular
from fastai.tabular.all import *
path = untar_data(URLs.ADULT_SAMPLE)
df = pd.read_csv(path/'adult.csv')
dls = TabularDataLoaders.from_csv(path/'adult.csv', path=path, y_names="salary",
cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race'],
cont_names = ['age', 'fnlwgt', 'education-num'],
procs = [Categorify, FillMissing, Normalize])
splits = RandomSplitter(valid_pct=0.2)(range_of(df))
to = TabularPandas(df, procs=[Categorify, FillMissing,Normalize],
cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race'],
cont_names = ['age', 'fnlwgt', 'education-num'],
y_names='salary',
)
#splits=splits)
dls = to.dataloaders(bs=64)
learn = tabular_learner(dls, metrics=accuracy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment