Kaggle competition: Dogs vs. Cats Redux: Kernels Edition
<SOS> metric: LogLoss Kaggle data source: dogs-vs.-cats-redux:-kernels-edition<choose_model_class>
import numpy as np
import pandas as pd
import zipfile
from sklearn.model_selection import train_test_split, KFold
from sklearn.metrics import log_loss, roc_auc_score
from sklearn.linear_model import LogisticRegression
import os
learn = cnn_learner(data, models.resnet50, metrics=accuracy, model_dir='/tmp/models')
 learn.lr_find()<train_model>
sample_submission = pd.read_csv('/kaggle/input/dogs-vs-cats-redux-kernels-edition/sample_submission.csv')
 sample_submission.tail()
%time learn.fit(2,slice(1e-2))<set_options>
TRAIN_FOLDER = '.. /input/cats-and-dogs-embedded-data/train/train/'
TEST_FOLDER = '.. /input/cats-and-dogs-embedded-data/test/test/'
IMG_SIZE = 224
learn.precompute=False
learn.unfreeze()<define_search_space>
train_image_list = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/train_image_list.npy')
 test_image_list = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/test_image_list.npy' )
lr = np.array([0.001, 0.0075, 0.01] )<train_model>
ids = [int(x.split('.')[0])for x in test_image_list]
ids[:20]
learn.fit_one_cycle(9,slice(2e-3,2e-5), wd=.1 )<predict_on_test>
target = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/target.npy' )
test_pred, test_y, test_loss = learn.get_preds(ds_type=DatasetType.Test, with_loss=True )<prepare_output>
train_DenseNet169 = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_2/train_DenseNet169.npy')
 test_DenseNet169 = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_2/test_DenseNet169.npy' )
submission_df = pd.DataFrame({'ImageId': range(1, len(test_y)+ 1), 'Label': result}, columns=['ImageId', 'Label'])
 submission_df.head()<save_to_csv>
X_train, X_val, y_train, y_val = train_test_split(train_DenseNet169, target, test_size=0.1, random_state=42 )
submission_df.to_csv("submission.csv",index=None )<import_modules>
%%time
lr = LogisticRegression(C=0.002, max_iter=10000)
 lr.fit(X_train, y_train )
import pandas as pd
import numpy as np
from scipy.stats import mode
from sklearn.svm import SVC
from sklearn import svm
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import AdaBoostClassifier<load_from_csv>
val_preds = lr.predict_proba(X_val)[:,1]
titanic=pd.read_csv("/kaggle/input/train.csv")
 df=titanic.copy()
df.head()<count_missing_values>
roc_auc_score(y_val, val_preds )
df.isnull().sum()<load_from_csv>
log_loss(y_val, val_preds )
test=pd.read_csv("/kaggle/input/test.csv")
 test_df=test.copy()
test_df.isnull().sum()<feature_engineering>
test_preds = lr.predict_proba(test_DenseNet169)[:,1]
<groupby><EOS> 
sample_submission['id'] = ids
sample_submission['label'] = test_preds
sample_submission.to_csv('submission.csv', index=False)
 sample_submission.head()