text_plain_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.metrics import accuracy_score

from sklearn.metrics import classification_report

from sklearn.metrics import classification_report

from sklearn.model_selection import train_test_split

import pandas as pd

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')

num_columns = train.select_dtypes(include=['number']).columns.tolist()
num_columns

cat_columns = train.select_dtypes(exclude=['number']).columns.tolist()
cat_columns

X = train.drop(['Survived', 'PassengerId', 'Ticket', 'Cabin', 'Name'], axis=1)
y = train['Survived']

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report
from sklearn.metrics import accuracy_score
log_r = LogisticRegression(random_state=0)
log_r.fit(X_train, y_train)

y_pred_lr = log_r.predict(X_test)
accuracy_score(y_test, y_pred_lr)

from sklearn.metrics import classification_report
print(classification_report(y_test, y_pred_lr))