text_plain_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('/kaggle/input/titanic/train.csv')
test = pd.read_csv('/kaggle/input/titanic/test.csv')

train.drop(['Name'], axis=1, inplace=True)
train.drop(['Cabin'], axis=1, inplace=True)
train.drop(['Ticket'], axis=1, inplace=True)
test.drop(['Name'], axis=1, inplace=True)
test.drop(['Cabin'], axis=1, inplace=True)
test.drop(['Ticket'], axis=1, inplace=True)

train = train[train['Embarked'].notna()]
train = train[train['Fare'] < 300]

train_clean = train.dropna(thresh=train.shape[1] - 1)
train = train_clean

ids = train['PassengerId']
train.drop(['PassengerId'], axis=1, inplace=True)
from sklearn.ensemble import AdaBoostClassifier
ids_test = test['PassengerId']
test.drop(['PassengerId'], axis=1, inplace=True)

labels = train['Survived']
train.drop(['Survived'], axis=1, inplace=True)

train['Sex'] = pd.factorize(train['Sex'])[0]
train['Embarked'] = pd.factorize(train['Embarked'])[0]
test['Sex'] = pd.factorize(test['Sex'])[0]
test['Embarked'] = pd.factorize(test['Embarked'])[0]

dummy_columns = ['Sex', 'Pclass', 'Embarked']
for column in dummy_columns:
    just_dummies = pd.get_dummies(train[column])
    train = pd.concat([train, just_dummies], axis=1)
    train = train.drop([column], axis=1)
for column in dummy_columns:
    just_dummies = pd.get_dummies(test[column])
    test = pd.concat([test, just_dummies], axis=1)
    test = test.drop([column], axis=1)

train.info()