Kaggle competition: Aerial Cactus Identification
<SOS> metric: AUC Kaggle data source: aerial-cactus-identification<categorify>
import numpy as np
import pandas as pd
from fastai import *
from fastai.vision import *
training_data['Sex'] = training_data['Sex'].map(sex_dict)
 training_data.head()<categorify>
data_folder = Path(".. /input/aerial-cactus-identification")
 train_df = pd.read_csv(".. /input/aerial-cactus-identification/train.csv")
 test_df = pd.read_csv(".. /input/aerial-cactus-identification/sample_submission.csv")
 test_img = ImageList.from_df(test_df, path=data_folder/'test', folder='test')
 trfm = get_transforms(do_flip=True, flip_vert=True, max_rotate=10.0, max_zoom=1.1, max_lighting=0.2, max_warp=0.2, p_affine=0.75, p_lighting=0.75)
 train_img =(ImageList.from_df(train_df, path=data_folder/'train', folder='train')
.split_by_rand_pct(0.01)
.label_from_df() 
.add_test(test_img)
.transform(trfm, size=128)
.databunch(bs=64, device= torch.device('cuda:0')) 
.normalize(imagenet_stats)
 )
testing_data['Sex'] = testing_data['Sex'].map(sex_dict)
 testing_data.head()<categorify>
learn = cnn_learner(train_img, models.resnet18, metrics=[error_rate, accuracy])
imp = Imputer(missing_values = 'NaN', strategy = 'mean', axis = 0)
 training_data[["Age"]] = imp.fit_transform(training_data[["Age"]] ).ravel()
testing_data[["Age"]] = imp.fit_transform(testing_data[["Age"]] ).ravel()
testing_data[["Fare"]] = imp.fit_transform(testing_data[["Fare"]] ).ravel()
training_data[["Embarked"]] = training_data[["Embarked"]].fillna(method = 'ffill')
 testing_data[["Embarked"]] = testing_data[["Embarked"]].fillna(method = 'ffill' )<count_missing_values>
lr = 3e-02
learn.fit_one_cycle(5, slice(lr))
training_data.isnull().sum(axis=0 )<count_missing_values>
preds,_ = learn.get_preds(ds_type=DatasetType.Test)
 test_df.has_cactus = preds.numpy() [:, 0]
test_df.to_csv('submission.csv', index=False )
testing_data.isnull().sum(axis=0 )<categorify>
FileLink('submission.csv' )