Kaggle competition: Titanic - Machine Learning from Disaster
<SOS> metric: categorizationaccuracy Kaggle data source: titanic-machine-learning-from-disaster<predict_on_test>
print(check_output(["ls", ".. /input"] ).decode("utf8"))
train_df = pd.read_csv('.. /input/train.csv')
 test_df = pd.read_csv('.. /input/test.csv')
test_preds = lr.predict_proba(test_InceptionResNetV2)[:,1]<save_to_csv>
new_age = pd.DataFrame()
new_age['Age'] = train_df.Age.fillna(train_df.Age.mean())
 new_age
sample_submission['id'] = ids
sample_submission['label'] = test_preds
sample_submission.to_csv('submission.csv', index=False)
 sample_submission.head()<import_modules>
import seaborn as sns
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 
<load_from_csv>
train_df.groupby(['Sex'] ).Survived.sum()
sample_submission = pd.read_csv('/kaggle/input/dogs-vs-cats-redux-kernels-edition/sample_submission.csv')
 sample_submission.tail()<define_variables>
print(train_df[train_df.Sex == 'female'].Survived.sum() /train_df[train_df.Sex == 'female'].Survived.count())
 print(train_df[train_df.Sex == 'male'].Survived.sum() /train_df[train_df.Sex == 'male'].Survived.count() )
TRAIN_FOLDER = '.. /input/cats-and-dogs-embedded-data/train/train/'
TEST_FOLDER = '.. /input/cats-and-dogs-embedded-data/test/test/'
IMG_SIZE = 224<load_pretrained>
data['Age'] = data.Age.fillna(data.Age.median())
 data['Fare'] = data.Fare.fillna(data.Fare.median())
 data.info()
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' )<define_variables>
data = pd.get_dummies(data, columns=['Sex'], drop_first=True)
 data.head()
ids = [int(x.split('.')[0])for x in test_image_list]
ids[:20]<load_pretrained>
data_train = data.iloc[:891]
data_test = data.iloc[891:]
X = data_train.values
test = data_test.values
y = survived_train.values
target = np.load('.. /input/cats-and-dogs-embedded-data/cats_and_dogs_1/target.npy' )<load_pretrained>
from sklearn import tree
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import GridSearchCV
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' )<split>
clf = tree.DecisionTreeClassifier(max_depth=3)
 clf.fit(X, y )
<train_model><EOS> 
Y_pred = clf.predict(test)
 test_df['Survived'] = Y_pred
test_df[['PassengerId', 'Survived']].to_csv('dec_tree.csv', index=False )