# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: automl_titanic
#     language: python
#     name: automl_titanic
# ---

# +
import pandas as pd

train = pd.read_csv('./data/train.csv')
train.shape

# +
from sklearn.tree import DecisionTreeClassifier

model = DecisionTreeClassifier()
# -

help(model.fit)

train.columns

X = train[['PassengerId', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp',
       'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked']]
y = train['Survived']

model.fit(X, y)

train.info()

X = train[['PassengerId', 'Pclass', 'Age', 'SibSp',
       'Parch', 'Fare']]
y = train['Survived']

model.fit(X, y)

X.info()

X['Age'].fillna(X['Age'].median(), inplace=True)
X.info()

model.fit(X, y)

test = pd.read_csv('./data/test.csv')
test.shape

model.predict(test)

# +
lil_test = test[['PassengerId', 'Pclass', 'Age', 'SibSp',
       'Parch', 'Fare']]

model.predict(lil_test)
# -

lil_test['Age'].fillna(lil_test['Age'].median(), inplace=True)
model.predict(lil_test)

lil_test.info()

lil_test['Fare'].fillna(lil_test['Fare'].median(), inplace=True)
model.predict(lil_test)

# +
y_predicted = model.predict(lil_test)

output = pd.DataFrame({'PassengerId': lil_test['PassengerId'], 'Survived': y_predicted})

output
# -

output.to_csv('./submissions/scikit_basic.csv', index=False)

StarcoderdataJupyterScriptsDedupFiltered