Kaggle competition: Aerial Cactus Identification
lgb_model = lgb.LGBMRegressor(objective = 'regression', num_leaves = 5,
learning_rate = 0.009, n_estimators = 5500,
max_bin = 200, bagging_fraction = 0.705,
bagging_freq = 5, feature_fraction = 0.2,
feature_fraction_seed = 9, bagging_seed = 9,
min_data_in_leaf = 2)
 sc = cross_val_score(lgb_model, X_train_TM, y_log, scoring = "neg_mean_squared_error", cv = 10)
 np.sqrt(-sc.mean())
 score = score.append({'model': 'LightGBM', 'score': np.sqrt(-sc.mean())}, ignore_index = True)
 print('The score of the LightGBM model:', np.sqrt(-sc.mean()))<categorify>
from pathlib import Path
from fastai import *
from fastai.vision import *
import torch
cleaned_X = clean_data(X)
 cleaned_X = add_features(cleaned_X)
 cleaned_X = add_polynomial(cleaned_X)
 cleaned_X = num_to_cat(cleaned_X)
 cleaned_X = transf_skewed(cleaned_X)
 numerical = [var for var in cleaned_X if cleaned_X[var].dtype != 'object']
columns_scaling =(cleaned_X[numerical].max() > 3 ).index.values
robust_scaler = RobustScaler()
cleaned_X[columns_scaling] = robust_scaler.fit_transform(cleaned_X[columns_scaling])
 remove_columns(cleaned_X)
 cleaned_X = one_hot_encoding(cleaned_X)
 X_train_LM = cleaned_X.iloc[:s, :]
X_test_LM = cleaned_X.iloc[s:, :]
X_train_LM.drop(outliers, inplace = True)
 print('Missing values in the cleaned training set:', X_train_LM.isnull().sum().sum())
 print('Missing values in the cleaned testing set:', X_test_LM.isnull().sum().sum() )<compute_train_metric>
train_df = pd.read_csv(".. /input/train.csv")
 test_df = pd.read_csv(".. /input/sample_submission.csv" )
lasso_model = linear_model.Lasso(alpha = 0.00046, max_iter = 500, fit_intercept = True)
 sc = cross_val_score(lasso_model, X_train_LM, y_log, scoring = "neg_mean_squared_error", cv = 10)
 score = score.append({'model': 'Lasso', 'score': np.sqrt(-sc.mean())}, ignore_index = True)
 print('The score of the Lasso model:', np.sqrt(-sc.mean()))<compute_train_metric>
test_img = ImageList.from_df(test_df, path=data_folder/'test', folder='test' )
elastic_model = linear_model.ElasticNet(alpha = 0.00046, l1_ratio = 1, fit_intercept = True, normalize = False,
precompute = False, max_iter = 500, copy_X = True, tol = 0.001, warm_start = False,
positive = False, random_state = 42, selection = 'cyclic')
 sc = cross_val_score(elastic_model, X_train_LM, y_log, scoring = "neg_mean_squared_error", cv = 10)
 score = score.append({'model': 'ElasticNet', 'score': np.sqrt(-sc.mean())}, ignore_index = True)
 print('The score of the ElasticNet model:', np.sqrt(-sc.mean()))<compute_train_metric>
train_img =(ImageList.from_df(train_df, path=data_folder/'train', folder='train')
.split_by_rand_pct(0.01)
.label_from_df() 
.add_test(test_img)
.transform(trfm, size=128)
.databunch(path='.', bs=64, device= torch.device('cuda:0')) 
.normalize(imagenet_stats)
 )
lassolars_model = LassoLarsIC(criterion = 'aic', eps = 0.3)
 sc = cross_val_score(lassolars_model, X_train_LM, y_log, scoring = "neg_mean_squared_error", cv = 10)
 score = score.append({'model': 'LassoLars', 'score': np.sqrt(-sc.mean())}, ignore_index = True)
 print('The score of the LassoLars model:', np.sqrt(-sc.mean()))<compute_train_metric>
learn = cnn_learner(train_img, models.resnet18, metrics=[error_rate, accuracy] )
svr_model = SVR(C= 20, epsilon = 0.0117, gamma = 0.00041)
 sc = cross_val_score(svr_model, X_train_LM, y_log, scoring = "neg_mean_squared_error", cv = 10)
 score = score.append({'model': 'SVR', 'score': np.sqrt(-sc.mean())}, ignore_index = True)
 print('The score of the SVR model:', np.sqrt(-sc.mean()))<compute_train_metric>
lr = 3e-02
learn.fit_one_cycle(5, slice(lr))
bridge_model = BayesianRidge(alpha_1 = 45, alpha_2 = 0, compute_score = False,
copy_X = True, fit_intercept = True, lambda_1 = 0, lambda_2 = 0,
n_iter = 500, normalize = False, tol = 0.001, verbose = False)
 sc = cross_val_score(bridge_model, X_train_LM, y_log, scoring = "neg_mean_squared_error", cv = 10)
 score = score.append({'model': 'BayesianRidge', 'score': np.sqrt(-sc.mean())}, ignore_index = True)
 print('The score of the BayesianRidge model:', np.sqrt(-sc.mean()))<categorify>
preds,_ = learn.get_preds(ds_type=DatasetType.Test )
cleaned_X = clean_data(X)
 cleaned_X = add_features(cleaned_X)
 cleaned_X = add_polynomial(cleaned_X)
 cleaned_X = num_to_cat(cleaned_X)
 cleaned_X = transf_skewed(cleaned_X)
 remove_columns(cleaned_X)
 cleaned_X = one_hot_encoding(cleaned_X)
 X_train_LM2 = cleaned_X.iloc[:s, :]
X_test_LM2 = cleaned_X.iloc[s:, :]
X_train_LM2.drop(outliers, inplace = True)
 print('Missing values in the cleaned training set:', X_train_LM2.isnull().sum().sum())
 print('Missing values in the cleaned testing set:', X_test_LM2.isnull().sum().sum() )<compute_train_metric>
test_df.has_cactus = preds.numpy() [:, 0]
kridge_model = KernelRidge(alpha = 7.5)
 sc = cross_val_score(kridge_model, X_train_LM2, y_log, scoring = "neg_mean_squared_error", cv = 10)
 score = score.append({'model': 'KernelRidge', 'score': np.sqrt(-sc.mean())}, ignore_index = True)
 print('The score of the KernelRidge model:', np.sqrt(-sc.mean()))<train_model>
test_df.to_csv('submission_resnet_18.csv', index=False )