Kaggle competition: Dogs vs. Cats Redux: Kernels Edition
<SOS> metric: LogLoss Kaggle data source: dogs-vs.-cats-redux:-kernels-edition<drop_column>
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
test_df.drop(['Name','Age','Ticket','Fare','Cabin','PassengerId'],axis=1,inplace=True )<count_missing_values>
sample_submission = pd.read_csv('/kaggle/input/dogs-vs-cats-redux-kernels-edition/sample_submission.csv')
 sample_submission.tail()
test_df.isnull().sum()<prepare_x_and_y>
TRAIN_FOLDER = '.. /input/cats-and-dogs-embedded-data/train/train/'
TEST_FOLDER = '.. /input/cats-and-dogs-embedded-data/test/test/'
IMG_SIZE = 224
ytrain=df["Survived"]
del df["Survived"]<prepare_x_and_y>
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' )
xtrain=df.values
xtest=test_df.values<train_on_grid>
ids = [int(x.split('.')[0])for x in test_image_list]
ids[:20]
n_estimators=list(range(100,1100,100))
learn_rate=[0.05,0.1,0.2,0.3,0.25,0.4,0.5,0.6,0.7,0.8,0.9,1]
hyper={'n_estimators':n_estimators,'learning_rate':learn_rate}
gd=GridSearchCV(estimator=AdaBoostClassifier() ,param_grid=hyper,verbose=True)
 gd.fit(xtrain,ytrain)
 print(gd.best_score_)
 print(gd.best_estimator_ )<train_model>
target = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/target.npy' )
clf=AdaBoostClassifier(n_estimators=200,random_state=0,learning_rate=0.05)
 clf.fit(xtrain,ytrain)
 print(clf.score(xtrain,ytrain))
ypred=clf.predict(xtest )<save_to_csv>
train_InceptionV3 = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/train_InceptionV3.npy')
 test_InceptionV3 = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/test_InceptionV3.npy' )
submission = pd.DataFrame({
"PassengerId": test["PassengerId"],
"Survived": ypred
})
 submission.to_csv('submission.csv', index=False )<import_modules>
X_train, X_val, y_train, y_val = train_test_split(train_InceptionV3, target, test_size=0.1, random_state=42 )
import keras
import numpy as np
import pandas as pd<load_from_csv>
%%time
lr = LogisticRegression(C=0.4, max_iter=10000)
 lr.fit(X_train, y_train )
train_df=pd.read_csv("/kaggle/input/digit-recognizer/train.csv")
 test_df=pd.read_csv("/kaggle/input/digit-recognizer/test.csv" )<prepare_x_and_y>
val_preds = lr.predict_proba(X_val)[:,1]
target=train_df["label"]
train_df.drop("label",axis=1,inplace=True )<categorify>
roc_auc_score(y_val, val_preds )
train_df=train_df/255
test_df=test_df/255<prepare_x_and_y>
log_loss(y_val, val_preds )
X_train=train_df.values.reshape(-1,28,28,1)
 test=test_df.values.reshape(-1,28,28,1 )<prepare_x_and_y>
test_preds = lr.predict_proba(test_InceptionV3)[:,1]
y_train=to_categorical(target,num_classes=10 )<split>
sample_submission['id'] = ids
sample_submission['label'] = test_preds
sample_submission.to_csv('submission.csv', index=False)
 sample_submission.head()