Kaggle competition: Aerial Cactus Identification
full.Age.isnull().sum()<statistical_test>
import os
import numpy as np
from fastai import *
from fastai.vision import *
age_estimator = full[['Age','TicketClass','Sibling_Spouse']]\ 
.groupby(['TicketClass','Sibling_Spouse'] ).agg(['mean','std'])
 age_nulls = full.loc[full.Age.isnull() ,:]
for idx,rec in age_nulls.iterrows() :
mean = age_estimator.loc[(rec['TicketClass'],rec['Sibling_Spouse']),('Age','mean')]
std = age_estimator.loc[(rec['TicketClass'],rec['Sibling_Spouse']),('Age','std')]
gen_age = random.uniform(mean-std, mean+std)
 full.loc[idx,'Age'] = gen_age if gen_age >= 1 else 1
full['Age'] = full['Age'].apply(math.ceil )<count_missing_values>
train_path = Path('.. /input/train')
 test_path = Path('.. /input/test')
 print(train_path, test_path)
full.Age.isnull().sum()<feature_engineering>
train_df = pd.read_csv('.. /input/train.csv')
 train_df.head(10 )
quantile_label = ['Cheap','Regular','Premium']
full['TicketFare'] = pd.qcut(full['TicketFare'],
q=quantile_list,
labels=quantile_label)
 full.TicketFare.value_counts().sort_values()<feature_engineering>
test_df = pd.read_csv('.. /input/sample_submission.csv')
full['FamilySize'] = full['Sibling_Spouse'] + \
full['Parent_Children'] + \
1<data_type_conversions>
test_data = ImageList.from_df(test_df, path = test_path, folder = 'test')
 train_data =(ImageList.from_df(train_df, path = train_path, folder = 'train')
.split_by_rand_pct(0.1)
.label_from_df() 
.add_test(test_data)
.transform(get_transforms() , size = 32)
.databunch(path = '.', bs = 64)
.normalize(imagenet_stats))
full.loc[full.FamilySize > 1, 'IsAlone'] = 0
full.loc[full.FamilySize <= 1, 'IsAlone'] = 1
full['IsAlone'] = full['IsAlone'].astype(int )<sort_values>
learner = cnn_learner(train_data, models.densenet161, metrics = [error_rate, accuracy] )
full.loc[:891,['FamilySize','Survived']]\ 
.groupby(['FamilySize'],as_index=False)\ 
.mean().sort_values(by='Survived', ascending=False )<sort_values>
learner.fit_one_cycle(8 )
full.loc[:891,['IsAlone','Survived']].groupby(['IsAlone'],as_index=False)\ 
.mean().sort_values(by='Survived', ascending=False )<drop_column>
learner.unfreeze()
learner.fit_one_cycle(4 )
full.drop(['Sibling_Spouse','Parent_Children'], axis=1, inplace=True )<categorify>
preds, _ = learner.get_preds(ds_type = DatasetType.Test)
 test_df.has_cactus = preds.numpy() [:, 0]
<categorify><EOS> 
test_df.to_csv('submission.csv', index = False )