Created
September 25, 2022 15:44
-
-
Save Ben-Karr/ee9ef0283c910e3e8db23e4e2667c2c5 to your computer and use it in GitHub Desktop.
Fastai minimal Quick-Start-Code: Tabular
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
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