Kaggle competition: Aerial Cactus Identification
<SOS> metric: AUC Kaggle data source: aerial-cactus-identification<categorify>
!pip install fastai==1.0.52
all_data=pd.get_dummies(all_data)
 print(np.shape(all_data))<import_modules>
from pathlib import Path
from fastai.vision import *
import torch
import random
from sklearn.model_selection import cross_val_score<choose_model_class>
PATH = Path('.. /input')

SEED = 2019
random.seed(SEED)
 torch.manual_seed(SEED)
 torch.backends.cudnn.deterministic = True
if torch.cuda.is_available() : torch.cuda.manual_seed_all(SEED)
 np.random.seed(SEED )
from sklearn.linear_model import ElasticNet, Lasso, BayesianRidge, LassoLarsIC
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import RobustScaler 
<choose_model_class>
batch_size = 96
ENet = make_pipeline(RobustScaler() , ElasticNet(alpha=0.0005, l1_ratio=.9, random_state=3))<choose_model_class>
tfms = get_transforms(flip_vert=True )
model_lgb = lgb.LGBMRegressor(objective='regression',num_leaves=5,
learning_rate=0.03, n_estimators=720,
max_bin = 55, bagging_fraction = 0.8,
bagging_freq = 5, feature_fraction = 0.2319,
feature_fraction_seed=9, bagging_seed=9,
min_data_in_leaf =6, min_sum_hessian_in_leaf = 11 )<choose_model_class>
src =(ImageList.from_csv(csv_name='train.csv', path=PATH, folder='train/train')
.split_by_rand_pct(0.1)
.label_from_df(cols='has_cactus'))
GBoost = GradientBoostingRegressor(n_estimators=3000, learning_rate=0.05,
max_depth=4, max_features='sqrt',
min_samples_leaf=15, min_samples_split=10,
loss='huber', random_state =5 )<choose_model_class>
data =(src.transform(tfms,size=128)
.databunch(bs=batch_size)
.normalize(imagenet_stats))
KRR = KernelRidge(alpha=0.6, kernel='polynomial', degree=2, coef0=2.5 )<import_modules>
data.show_batch(rows=3, figsize=(9, 9))
from xgboost import XGBRegressor,XGBRFRegressor
from lightgbm import LGBMRegressor<compute_train_metric>
data.classes, data.c
scores=-1 * cross_val_score(XGBRegressor(n_estimators=2200,learning_rate=0.05),xtrain,ytrain,cv=5,scoring="neg_mean_absolute_error" )<compute_test_metric>
learn = cnn_learner(data, models.densenet161, metrics=accuracy, path='./' )
val_score=scores.mean()<train_model>
lr = 3e-2
learn.fit_one_cycle(4,slice(lr))
model_lgb.fit(xtrain,ytrain )<train_model>
data =(src.transform(tfms, size=128)
.add_test_folder('test/test')
.databunch() 
.normalize(imagenet_stats))
GBoost.fit(xtrain,ytrain )<train_model>
learn.data = data
KRR.fit(xtrain,ytrain )<train_model>
probs, _ = learn.get_preds(ds_type=DatasetType.Test )
ENet.fit(xtrain,ytrain)
<train_model>
ilst = data.test_ds.x
model=XGBRegressor(n_estimators=2200,learning_rate=0.05)
 model.fit(xtrain,ytrain )<predict_on_test>
fnames = [item.name for item in ilst.items]; fnames[:10]
x=model.predict(test )<prepare_output>
test_df = pd.DataFrame({'id': fnames, 'has_cactus': probs.numpy() [:,0]}); test_df.head()
<predict_on_test><EOS> 
test_df.to_csv('submission.csv', index=None )