Kaggle competition: Aerial Cactus Identification
<SOS> metric: AUC Kaggle data source: aerial-cactus-identification<train_on_grid>
!pip install autokeras
!pip install natsort
ridge_cv = RidgeCV(alphas=(0.01, 0.05, 0.1, 0.3, 1, 3, 5, 10))
ridge_cv.fit(Xtrain, ytrain)
 val_ridge_cv = np.expm1(ridge_cv.predict(Xtest))
rmlse(val_ridge_cv, ytest )<predict_on_test>
import autokeras as ak
import numpy as np
import pandas as pd
from glob import glob
from skimage.io import imread
import skimage.io as sio
import os
from natsort import natsorted
import matplotlib.pyplot as plt
from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score, roc_auc_score
from skimage.transform import resize, rotate
import warnings; warnings.filterwarnings("ignore" )
las = linear_model.Lasso(alpha=0.0005 ).fit(Xtrain, ytrain)
 las_ridge = np.expm1(las.predict(Xtest))
rmlse(las_ridge, ytest )<train_on_grid>
root_dir = ".. /input"
train_dir = root_dir + "/train/train/"
test_dir = root_dir + "/test/test/"
csv_path = root_dir + "/train.csv"
sub_path = root_dir + "sample_submission.csv"
df = pd.read_csv(csv_path)
 x = np.array([ imread(train_dir+p)/255 for p in df.id.values])
 y = df.has_cactus.values
las_cv = LassoCV(alphas=(0.0001, 0.0005, 0.001, 0.01, 0.05, 0.1, 0.3, 1, 3, 5, 10))
las_cv.fit(Xtrain, ytrain)
 val_las_cv = np.expm1(las_cv.predict(Xtest))
rmlse(val_las_cv, ytest )<train_model>
x_train, x_val, y_train, y_val = train_test_split(x, y, test_size=0.20,stratify=y )
model_xgb = xgb.XGBRegressor(n_estimators=340, max_depth=2, learning_rate=0.2)
 model_xgb.fit(Xtrain, ytrain)
 xgb_preds = np.expm1(model_xgb.predict(Xtest))
rmlse(xgb_preds, ytest )<train_model>
runFor = 5
model = ak.ImageClassifier(verbose=True, augment=True)
 model.fit(x_train, y_train, time_limit=4*60*60 )
forest = RandomForestRegressor(min_samples_split =5,
min_weight_fraction_leaf = 0.0,
max_leaf_nodes = None,
max_depth = None,
n_estimators = 300,
max_features = 'auto')
 forest.fit(Xtrain, ytrain)
 Y_pred_RF = np.expm1(forest.predict(Xtest))
rmlse(Y_pred_RF, ytest )<feature_engineering>
y_pred = model.predict(x_train)
 y_prob = getProb(model, x_train)
 print("training accuracy = ", accuracy_score(y_train, y_pred))
print("training recall = ", recall_score(y_train, y_pred))
print("training precision = ", precision_score(y_train, y_pred))
print("training auc score = ", roc_auc_score(y_train, y_prob))
print("training f1 score = ", f1_score(y_train, y_pred))
y_pred = model.predict(x_val)
 y_prob = getProb(model, x_val)
 print("validation accuracy = ", accuracy_score(y_val, y_pred))
print("validation recall = ", recall_score(y_val, y_pred))
print("validation precision = ", precision_score(y_val, y_pred))
print("validation auc score = ",roc_auc_score(y_val, y_prob))
print("validation f1 score = ", f1_score(y_val, y_pred))
X_test['RoofMatl_ClyTile'] = 0<drop_column>
df_test = pd.read_csv('.. /input/sample_submission.csv')
 x_test = np.array([ imread(test_dir+p)/255 for p in df_test.id.values])
 x_test = np.array(x_test)
 y_prob_test = getProb(model, x_test)
 df_test['has_cactus'] = y_prob_test
df_test.to_csv('cactus_net_submission.csv', index=False )