text_plain_output_1.png
from sklearn.compose import ColumnTransformer

from sklearn.impute import SimpleImputer

from sklearn.pipeline import Pipeline

from sklearn.preprocessing import StandardScaler,OneHotEncoder

import pandas as pd

import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.impute import SimpleImputer
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt
ss = StandardScaler()
OneHot = OneHotEncoder()
Imputer = SimpleImputer()

train_data = pd.read_csv('../input/titanic/train.csv')
train_data.keys()

drop_train_data = train_data.drop(['Name', 'PassengerId', 'Cabin', 'Ticket'], axis=1).dropna(axis=0)
train_data['Family'] = train_data['SibSp'] + train_data['Parch']
train_data.corr()

y = drop_train_data.pop('Survived')

OneHot.fit_transform(drop_train_data['Embarked'])

num_pipeline = Pipeline([('imputer', Imputer), ('scaler', ss)])

num_attrib = ['Fare', 'Age']
txt_attrib = ['Sex', 'Embarked']
full_pipeline = ColumnTransformer([('num', num_pipeline, num_attrib), ('txt_trans', OneHot, txt_attrib)])
data_pred = full_pipeline.fit_transform(drop_train_data)
data = pd.DataFrame(data_pred)

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

drop_test_data = test_data.drop(['Name', 'PassengerId', 'Cabin', 'Ticket'], axis=1).dropna(axis=0)
drop_test_data['Family'] = drop_test_data['SibSp'] + drop_test_data['Parch']
drop_test_data