text_plain_output_1.png
from sklearn import svm

import numpy as np # linear algebra

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

train = pd.read_csv('../input/train.csv')

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

PassengerIds = test['PassengerId']
PassengerIds

train['Sex'] = train['Sex'].apply(lambda x: 1 if x == 'male' else 0)

train['Age'] = train['Age'].fillna(np.mean(train['Age']))
train['Fare'] = train['Fare'].fillna(np.mean(train['Fare']))

from sklearn import svm
clf = svm.SVC()
clf.fit(X_train, Y_train)

clf.score(X_train, Y_train)

clf.fit(X_test, Y_test)

clf.score(X_test, Y_test)

test['Sex'] = test['Sex'].apply(lambda x: 1 if x == 'male' else 0)
test['Age'] = test['Age'].fillna(np.mean(test['Age']))
test['Fare'] = test['Fare'].fillna(np.mean(test['Fare']))
test = test[['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare']]
results = clf.predict(test)

submission_df = {'PassengerId': PassengerIds, 'Survived': results}
submission = pd.DataFrame(submission_df)

submission