text_plain_output_1.png
from sklearn import preprocessing

from sklearn.linear_model import LogisticRegression

import pandas as pd

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

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

train.drop('Name', axis=1, inplace=True)
test.drop('Name', axis=1, inplace=True)

train.drop('Ticket', axis=1, inplace=True)
test.drop('Ticket', axis=1, inplace=True)

train.isnull().sum()

train.drop('Cabin', axis=1, inplace=True)
test.drop('Cabin', axis=1, inplace=True)

scaler = preprocessing.StandardScaler()
scaler.fit(train[['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked']])

X_train = scaler.transform(train[['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked']])

X_test = scaler.transform(test[['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked']])

from sklearn.linear_model import LogisticRegression
algo = LogisticRegression(C=90000, solver='sag', max_iter=15000)

algo.fit(X_train, train['Survived'])

algo.score(X_train, train['Survived'])

ans = algo.predict(X_test)

id1 = list(test['PassengerId'])
type(id1)

data = []
for i in range(len(ans)):
    temp = {}
    temp['PassengerId'] = id1[i]
    temp['Survived'] = ans[i]
    data.append(temp)
data