Kaggle competition: Aerial Cactus Identification
<SOS> metric: AUC Kaggle data source: aerial-cactus-identification<categorify>
sex_mapping = {"male":0, "female":1}
for dataset in train_test_data:
dataset["Sex"] = dataset["Sex"].map(sex_mapping )<categorify>
import numpy as np
import pandas as pd
import torch
from fastai import *
from fastai.vision import *
train["Age"].fillna(train.groupby("Title")["Age"].transform("median"), inplace=True)
 test["Age"].fillna(test.groupby("Title")["Age"].transform("median"), inplace=True )<feature_engineering>
train_df = pd.read_csv(".. /input/train.csv")
 test_df = pd.read_csv(".. /input/sample_submission.csv" )
for dataset in train_test_data:
dataset.loc[dataset['Age'] <= 16, 'Age'] = 0,
dataset.loc[(dataset['Age'] > 16)&(dataset['Age'] <= 26), 'Age'] = 1,
dataset.loc[(dataset['Age'] > 26)&(dataset['Age'] <= 36), 'Age'] = 2,
dataset.loc[(dataset['Age'] > 36)&(dataset['Age'] <= 62), 'Age'] = 3,
dataset.loc[dataset['Age'] > 62, 'Age'] = 4<count_values>
test_img = ImageList.from_df(test_df, path='.. /input/test', folder='test' )
Pclass1 = train[train['Pclass']==1]['Embarked'].value_counts()
Pclass2 = train[train['Pclass']==2]['Embarked'].value_counts()
Pclass3 = train[train['Pclass']==3]['Embarked'].value_counts()
df = pd.DataFrame([Pclass1, Pclass2, Pclass3])
 df.index = ['1st class', '2nd index', '3rd class']
df.plot(kind='bar',stacked = True, figsize=(10,5))<data_type_conversions>
learn2 = cnn_learner(train_img2, models.densenet161, metrics=[error_rate, accuracy] )
for dataset in train_test_data:
dataset['Embarked'] = dataset['Embarked'].fillna('S' )<categorify>
learn2.fit_one_cycle(5, slice(3e-02))
embarked_mapping = {"S":0, "C":1, "Q":2}
for dataset in train_test_data:
dataset['Embarked'] = dataset['Embarked'].map(embarked_mapping )<categorify>
preds,_ = learn2.get_preds(ds_type=DatasetType.Test )
train["Fare"].fillna(train.groupby("Pclass")["Fare"].transform("median"), inplace=True)
 test["Fare"].fillna(test.groupby("Pclass")["Fare"].transform("median"), inplace=True )<feature_engineering>
test_df.has_cactus = preds.numpy() [:, 0]
<count_values><EOS> 
test_df.to_csv('submission.csv', index=False)