Kaggle competition: Aerial Cactus Identification
<compute_train_metric>
from fastai.vision import *
lr = LogisticRegression(C = 100,penalty = 'l2', solver = 'newton-cg',class_weight = 'dict', max_iter = 900)
 Estimator.append(( 'lr',LogisticRegression(C = 1,penalty = 'l2', solver = 'newton-cg',class_weight = 'dict', max_iter = 900)))
 cv = cross_val_score(lr,x_train,x_test,cv=10)
 Accuracy1 = cv.mean()
Accuracy.append(Accuracy1)
 print(cv)
 print(cv.mean() )<train_model>
path = Path(".. /input/")
 tfms = get_transforms(flip_vert=True, do_flip=True)
 data = ImageDataBunch.from_csv(path=path, csv_labels='train.csv', folder='train/train',
test='test/test',ds_tfms = tfms)
 data
lr.fit(x_train,x_test)
 lr.score(y_train,y_test )<save_to_csv>
learn = cnn_learner(data, models.resnet50, model_dir="/tmp/model/",
metrics = [error_rate, accuracy] )
model11pred = lr.predict(y_train)
 submission11 = pd.DataFrame(columns = ['PassengerId','Survived'])
 submission11['PassengerId'] = result['PassengerId']
submission11['Survived'] = model11pred
submission11.to_csv('LogisticRegression(HT ).csv',index = False )<train_on_grid>
learn.lr_find()
<compute_train_metric>
learn.fit_one_cycle(1, 1e-2 )
svc = LinearSVC(C = 0.1,penalty = 'l2', loss = 'hinge',class_weight = 'balanced')
 cv = cross_val_score(svc,x_train,x_test,cv=10)
 Accuracy2 = cv.mean()
Accuracy.append(Accuracy2)
 print(cv)
 print(cv.mean() )<train_model>
learn.save('fit-first-epoch' )
svc.fit(x_train,x_test)
 svc.score(y_train,y_test )<save_to_csv>
learn.load('fit-first-epoch');
model12pred = svc.predict(y_train)
 submission12 = pd.DataFrame(columns = ['PassengerId','Survived'])
 submission12['PassengerId'] = result['PassengerId']
submission12['Survived'] = model12pred
submission12.to_csv('SVCLinear(HT ).csv',index = False )<train_on_grid>
learn.fit_one_cycle(11, slice(1e-4, 2e-3))
<compute_train_metric>
learn.save('after-11-epochs');
SVM_all = svm.SVC(C = 1,degree = 2, kernel = 'poly',class_weight = 'balanced',gamma = 'scale')
 cv = cross_val_score(svc,x_train,x_test,cv=10)
 Accuracy3 = cv.mean()
Accuracy.append(Accuracy3)
 print(cv)
 print(cv.mean() )<train_model>
preds,_ = learn.get_preds(ds_type=DatasetType.Test )
SVM_all.fit(x_train,x_test)
 SVM_all.score(y_train,y_test )<save_to_csv>
test_df = pd.read_csv(".. /input/sample_submission.csv")
 test_df.has_cactus = preds.numpy() [:, 1]
model13pred = SVM_all.predict(y_train)
 submission13 = pd.DataFrame(columns = ['PassengerId','Survived'])
 submission13['PassengerId'] = result['PassengerId']
submission13['Survived'] = model13pred
submission13.to_csv('PolynomialSVM(HT ).csv',index = False )<train_on_grid>
to_np(p )
<compute_train_metric><EOS> 
test_df.to_csv('submission.csv', index=False )