<jupyter_start><jupyter_text>Tabular data* Load data into pandas* Examine* Impute* Create tabular databunch* Create tabular fastai learner* Train* Evaluate<jupyter_code>from fastai.tabular import *
path = untar_data(URLs.ADULT_SAMPLE)
df = pd.read_csv(path/'adult.csv')
df
dep_var = 'salary'
cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race']
cont_names = ['age', 'fnlwgt', 'education-num']
procs = [FillMissing, Categorify, Normalize]
procs
len(df)
test = TabularList.from_df(df.iloc[800:1000].copy(), path=path, cat_names=cat_names, cont_names=cont_names)
data = (TabularList.from_df(path=path, df=df, cat_names=cat_names, cont_names=cont_names, procs=procs)
            .split_by_idx(list(range(800,1000)))
            .label_from_df(cols=dep_var)
            .add_test(test)
            .databunch())
data.show_batch(rows=10)
learner = tabular_learner(data, layers=[200,100], metrics=accuracy)
learner.lr_find()
learner.recorder.plot()
learner.fit_one_cycle(10, max_lr=1e-1)
learner.fit_one_cycle(5, max_lr=1e-2)
learner.fit_one_cycle(5, max_lr=1e-3)
learner.fit_one_cycle(5, max_lr=1e-4)<jupyter_output><empty_output><jupyter_text>Predict<jupyter_code>row = df.iloc[0]
learner.predict(row)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14511041009463724, 'fraction_numerical': 0.028391167192429023, 'mean_word_length': 6.785276073619632, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '432332', 'license': 'Apache-2.0', 'n_tokens_mistral': 525, 'n_tokens_neox': 501, 'n_words': 75, 'path': 'nbs/dl1/lesson4-tabular-own.ipynb', 'repo_name': 'webmartingale/fastai-course-v3', 'size': '1268'}