Kaggle competition: Aerial Cactus Identification
PassengerId = test['PassengerId']
feature_columns = ['Sex','Pclass', 'Embarked', 'Title','SibSp', 'Parch', 'Age', 'Fare', 'FamilySize', 'IsAlone', 'Age*Class']
train = train[feature_columns + ['Survived']]
test = test[feature_columns]
train.head()<prepare_x_and_y>
!pip install efficientnet_pytorch
classifiers = []
ntrain = train.shape[0]
ntest = test.shape[0]
kfold = StratifiedKFold(n_splits=10)
 y_train = train['Survived'].ravel()
x_train = train.drop(['Survived'], axis=1 ).values
x_train_columns = train.drop(['Survived'], axis=1 ).columns
x_test = test.values
def classifier_name(clf):
if 'ABCMeta' == clf.__class__:
return clf.__name__
else:
return clf.__class__.__name__<init_hyperparams>
path = Path('.. /input/' )
rf_params = {
'n_jobs': -1,
'n_estimators': 500,
'warm_start': False,
'min_samples_leaf': 2,
'max_features' : 'sqrt',
'verbose': 0,
'random_state': RANDOM_SEED
}
rf = RandomForestClassifier(**rf_params)
 classifiers.append(rf )<set_options>
path.ls()
svm_params = {'probability': True,
'random_state': RANDOM_SEED}
svm = SVC(**svm_params)
 classifiers.append(svm )<choose_model_class>
train = pd.read_csv(path/'train.csv')
 test = pd.read_csv(path/'sample_submission.csv' )
lr_params = {
'solver': 'liblinear',
'random_state': RANDOM_SEED
}
lr = LogisticRegression(**lr_params)
 classifiers.append(lr )<choose_model_class>
test_img = ImageList.from_df(test, path=path/'test', folder='test')
 tfms = get_transforms()
data =(ImageList.from_df(train, path=path/'train', folder='train')
.split_by_rand_pct(0.01)
.label_from_df() 
.add_test(test_img)
.transform(tfms, size=224, resize_method=ResizeMethod.SQUISH)
.databunch(path='.', bs=64, device= torch.device('cuda:0')) 
.normalize(imagenet_stats)
 )
kn_params = {'n_neighbors': 3}
kn = KNeighborsClassifier(**kn_params)
 classifiers.append(kn )<choose_model_class>
from efficientnet_pytorch import EfficientNet
gb_params = {'random_state':RANDOM_SEED}
gb = GradientBoostingClassifier(**gb_params)
 classifiers.append(gb )<choose_model_class>
model_name = 'efficientnet-b3'
def getModel(pret):
model = EfficientNet.from_pretrained(model_name)
 model._fc = nn.Linear(model._fc.in_features,data.c)
 return model
dt_params = {'random_state':RANDOM_SEED}
dt = DecisionTreeClassifier(**dt_params)
 classifiers.append(dt )<choose_model_class>
learn = Learner(data,getModel(True),metrics=[accuracy] )
ab_params = {'random_state':RANDOM_SEED}
ab = AdaBoostClassifier(**ab_params)
 classifiers.append(ab )<choose_model_class>
lr=5e-3
gnb_params = {}
gnb = GaussianNB(**gnb_params)
 classifiers.append(gnb )<choose_model_class>
learn.fit_one_cycle(3,lr )
ld_params = {}
ld = LinearDiscriminantAnalysis(**ld_params)
 classifiers.append(ld )<choose_model_class>
preds,_ = learn.get_preds(ds_type=DatasetType.Test)
 idx = preds.numpy() [:,0]
<choose_model_class><EOS> 
test.has_cactus = idx
test.to_csv('submission.csv', index=False )