<jupyter_start><jupyter_text>Setup<jupyter_code>!pip install fastai -U 
import fastai
fastai.__version__
from fastai.tabular.all import *<jupyter_output><empty_output><jupyter_text>Data<jupyter_code>path = '../input/titanic'
train_path = path + '/train.csv'
test_path = path + '/test.csv'
train = pd.read_csv(train_path)
train.head()
train.Parch.describe()
train.columns
splits = RandomSplitter(valid_pct=0.2)(range_of(train))
data = TabularPandas(
    train,
    procs=[Categorify, FillMissing,Normalize],
    cat_names = ['Pclass', 'SibSp', 'Sex', 'Parch','Cabin','Embarked'],
    cont_names = ['Age','Fare'],
    y_names='Survived',
    splits=splits)<jupyter_output><empty_output><jupyter_text>Train<jupyter_code>dls = data.dataloaders(bs=64)
learn = tabular_learner(dls, metrics=accuracy, cbs=ShowGraphCallback())
learn.fit_one_cycle(150)<jupyter_output><empty_output><jupyter_text>Test<jupyter_code>test = pd.read_csv(test_path)
test.head()
test = test.fillna(0)
dl = learn.dls.test_dl(test)
result = learn.get_preds(dl=dl)
results = pd.DataFrame(columns=['PassengerId', 'Survived'])
for i, row in test.iterrows():
    pass_id = row['PassengerId']
    pred = learn.predict(row)
    if (pred[1] < 0.5):
        survived = 0
    else:
        survived = 1
    
    results.loc[i] = [pass_id, survived]
        
results
results.to_csv('preds.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15362526920315864, 'fraction_numerical': 0.00933237616654702, 'mean_word_length': 5.6380952380952385, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '312319', 'license': 'Apache-2.0', 'n_tokens_mistral': 556, 'n_tokens_neox': 546, 'n_words': 79, 'path': 'notebooks/titanic.ipynb', 'repo_name': 'aryanfaghihi/fastai-life', 'size': '1393'}