Kaggle competition: Dogs vs. Cats Redux: Kernels Edition
<SOS> metric: LogLoss Kaggle data source: dogs-vs.-cats-redux:-kernels-edition<train_model>
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
model.fit(X,y )<predict_on_test>
sample_submission = pd.read_csv('/kaggle/input/dogs-vs-cats-redux-kernels-edition/sample_submission.csv')
 sample_submission.tail()
pred_y = model.predict(X_test )<save_to_csv>
TRAIN_FOLDER = '.. /input/cats-and-dogs-embedded-data/train/train/'
TEST_FOLDER = '.. /input/cats-and-dogs-embedded-data/test/test/'
IMG_SIZE = 224
output = pd.DataFrame({'PassengerId': test_data.PassengerId, 'Survived': pred_y})
 output.to_csv('my_submission.csv', index=False)
 print("Submitted successfully!" )<set_options>
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' )
warnings.filterwarnings("ignore", category=DeprecationWarning)
 sns.set()<load_from_csv>
ids = [int(x.split('.')[0])for x in test_image_list]
ids[:20]
train_data = pd.read_csv(".. /input/titanic/train.csv" )<drop_column>
target = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/target.npy' )
train_data.drop(columns=['Name', 'Ticket', 'Cabin','PassengerId'], axis=1, inplace=True )<categorify>
train_DenseNet121 = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_2/train_DenseNet121.npy')
 test_DenseNet121 = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_2/test_DenseNet121.npy' )
train_data['Sex'] = train_data['Sex'].map({'male':0,'female':1} )<count_missing_values>
X_train, X_val, y_train, y_val = train_test_split(train_DenseNet121, target, test_size=0.1, random_state=42 )
train_data['Age'].isnull().sum()<count_values>
%%time
lr = LogisticRegression(C=0.002, max_iter=10000)
 lr.fit(X_train, y_train )
train_data['Embarked'].value_counts()<data_type_conversions>
val_preds = lr.predict_proba(X_val)[:,1]
train_data['Embarked'].fillna(value='S',axis=0, inplace=True )<categorify>
roc_auc_score(y_val, val_preds )
train_data['Embarked'] = train_data['Embarked'].map({'S':0,'C':1,'Q':2} )<data_type_conversions>
log_loss(y_val, val_preds )
train_data.fillna(value=train_data['Age'].mean() , axis=0, inplace=True )<groupby>
test_preds = lr.predict_proba(test_DenseNet121)[:,1]
train_data[['Pclass', 'Survived']].groupby(['Pclass'], as_index=False ).mean()<groupby>
sample_submission['id'] = ids
sample_submission['label'] = test_preds
sample_submission.to_csv('submission.csv', index=False)
 sample_submission.head()