Kaggle competition: Aerial Cactus Identification
check_list = [[146, 550, 1068, 1222], [270, 326, 374, 1206], [280, 747, 1065, 1284], [291, 742, 988], [298, 306, 499, 709, 1033, 1198],
[308, 506, 1306], [381, 558, 701, 717, 1094], [538, 545, 1131]]
fillfull_p2(combine,check_list,check_more = [] )<filter>
%matplotlib inline
survival = combine[(combine.Pclass_Gender=="P3-Man")&(combine.Ave_Survival==0.5)]["Survived"].mean()
shape = combine[(combine.Pclass_Gender=="P3-Man")&(combine.Ave_Survival==0.5)&(combine.Survived.notna())].shape[0]
print(survival)
 print(shape )<filter>
train_df = pd.read_csv(".. /input/train.csv")
 train_df.head()
survival = combine[(combine.Pclass_Gender=="P1-Man")&(combine.Ave_Survival==0.5)]["Survived"].mean()
shape = combine[(combine.Pclass_Gender=="P1-Man")&(combine.Ave_Survival==0.5)&(combine.Survived.notna())].shape[0]
print(survival)
 print(shape )<filter>
data_folder = Path(".. /input")
 train_img = ImageList.from_df(train_df, path=data_folder, folder='train/train' )
survival =combine[(combine.Pclass_Gender=="P3-Boy")&(combine.Ave_Survival==0.5)]["Survived"].mean()
shape = combine[(combine.Pclass_Gender=="P3-Boy")&(combine.Ave_Survival==0.5)&(combine.Survived.notna())].shape[0]
print(survival)
 print(shape )<filter>
transformations = 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 )
combine[(combine.Pclass_Gender=="P3-Boy")&(combine.Ave_Survival==0.5)
 &(combine.Survived.isna())][["PassengerId","Ticket","Ticket_Counts"]]<filter>
test_df = pd.read_csv(".. /input/sample_submission.csv")
 test_img = ImageList.from_df(test_df, path=data_folder, folder='test/test' )
combine[combine.Ticket=="2673"][["PassengerId","Age","Pclass_Gender","Survived","Ave_Survival"]]<feature_engineering>
train_img = train_img.split_by_rand_pct(0.01 ).label_from_df().add_test(test_img ).transform(transformations, size=128 ).databunch(path='.', bs=64, device=torch.device('cuda:0')).normalize(imagenet_stats )
combine.loc[(combine.Pclass_Gender.isin(["P3-Woman"])) &(combine.Ave_Survival>=0.5),"If_Survived"] = 1
combine.loc[(combine.Pclass_Gender.isin(["P3-Woman"])) &(combine.Ave_Survival<0.5),"If_Survived"] = 0
combine.loc[(combine.Pclass_Gender.isin(["P1-Man","P3-Man"])&(combine.Ave_Survival>0.5)) ,"If_Survived"] = 1
combine.loc[(combine.Pclass_Gender.isin(["P1-Man","P3-Man"])&(combine.Ave_Survival<=0.5)) ,"If_Survived"] = 0
combine.loc[(( combine.Pclass_Gender.isin(["P3-Boy"])) &(combine.Ave_Survival>0.5)) ,"If_Survived"] = 1
combine.loc[(( combine.Pclass_Gender.isin(["P3-Boy"])) &(combine.Ave_Survival<0.5)) ,"If_Survived"] = 0
combine.loc[(combine.PassengerId.isin([1053,1199,1309])) ,"If_Survived"] = 1
combine.loc[(combine.PassengerId.isin([1046,1084,1231,1236,1271,1284])) ,"If_Survived"] = 0
combine.loc[(combine.Group_size.isna()),"Group_size"] = 1<filter>
learn = cnn_learner(train_img, models.densenet161, metrics=[error_rate, accuracy] )
combine[(combine.Pclass_Gender.isin(["P1-Man","P3-Man"]))
&(combine.Survived.isna())&(combine.If_Survived==1)][["Pclass_Gender","Group_size","Ave_Survival","Ticket"]]<feature_engineering>
lr = 3e-02
learn.fit_one_cycle(5, slice(lr))
<drop_column><EOS> 
preds, _ = learn.get_preds(ds_type=DatasetType.Test)
 test_df.has_cactus = preds.numpy() [:,0]
test_df.to_csv('submission.csv', index=False )