Kaggle competition: Aerial Cactus Identification
<SOS> metric: AUC Kaggle data source: aerial-cactus-identification<train_model>
import pandas as pd
import numpy as np
import cv2
from zipfile import ZipFile
from fastai import *
from fastai.vision import *
rf.fit(x_train,x_test)
 rf.score(y_train,y_test )<save_to_csv>
def unzip_folder(path=None,folder_name='train',extract_to=None):

 with ZipFile(path+folder_name+'.zip', 'r')as zip:
print('Extracting all the files now from '+folder_name+'...')
 zip.extractall(path=extract_to)
 print('Done!' )
model16pred = rf.predict(y_train)
 submission16 = pd.DataFrame(columns = ['PassengerId','Survived'])
 submission16['PassengerId'] = result['PassengerId']
submission16['Survived'] = model16pred
submission16.to_csv('RandomForest(HT ).csv',index = False )<define_search_space>
unzip_folder(path='/kaggle/input/aerial-cactus-identification/',folder_name='train')
 unzip_folder(path='/kaggle/input/aerial-cactus-identification/',folder_name='test')
<train_on_grid>
df=pd.read_csv('/kaggle/input/aerial-cactus-identification/train.csv' )
<compute_train_metric>
df['has_cactus'].value_counts()
gbc = GradientBoostingClassifier(loss = 'exponential',n_estimators =200 ,min_samples_split = 4,max_features = 'auto',max_depth =9,learning_rate =.01,subsample =.1)
 Estimator.append(( 'gbc',GradientBoostingClassifier(loss = 'exponential',n_estimators =200 ,min_samples_split = 4,max_features = 'auto',max_depth =9,learning_rate =.01,subsample =.1)))
 cv = cross_val_score(gbc,x_train,x_test,cv=10)
 Accuracy7 = cv.mean()
Accuracy.append(Accuracy7)
 print(cv)
 print(cv.mean() )<train_model>
df.isnull().sum()
gbc.fit(x_train,x_test)
 gbc.score(y_train,y_test )<save_to_csv>
lean_den161=cnn_learner(data, models.densenet161, metrics=accuracy )
model17pred = gbc.predict(y_train)
 submission17 = pd.DataFrame(columns = ['PassengerId','Survived'])
 submission17['PassengerId'] = result['PassengerId']
submission17['Survived'] = model17pred
submission17.to_csv('GradientBoosting(HT ).csv',index = False )<define_search_space>
lean_den161.fit_one_cycle(7 )
<train_on_grid>
lean_den161.unfreeze()
<compute_train_metric>
lean_den161.fit_one_cycle(2, max_lr=slice(1e-5))
xgb = XGBClassifier(colsample_bytree =.6,eta = 0.5,gamma = 1,max_depth = 5,min_child_weight = 6,subsample = 1)
 Estimator.append(( 'xgb',XGBClassifier(colsample_bytree =.6,eta = 0.5,gamma = 1,max_depth = 5,min_child_weight = 6,subsample = 1)))
 cv = cross_val_score(xgb,x_train,x_test,cv=10)
 Accuracy8 = cv.mean()
Accuracy.append(Accuracy8)
 print(cv)
 print(cv.mean() )<train_model>
file=[]
for root, dirs, files in os.walk(path):
for filename in files:
file.append(filename )
xgb.fit(x_train,x_test)
 gbc.score(y_train,y_test )<save_to_csv>
submission_df=pd.DataFrame({'id': file, 'has_cactus': 1} )
model18pred = xgb.predict(y_train)
 submission18 = pd.DataFrame(columns = ['PassengerId','Survived'])
 submission18['PassengerId'] = result['PassengerId']
submission18['Survived'] = model18pred
submission18.to_csv('XGBoosting(HT ).csv',index = False )<normalization>
i=0
for image in submission_df.id:
img=open_image(path+'/'+image)
 pred_class,pred_idx,outputs = lean_den161.predict(img)
 submission_df.iloc[i,1]=pred_class
i=i+1
<find_best_params><EOS> 
submission_df.to_csv('submission.csv', header=True, index=False )