text_plain_output_1.png
from sklearn.metrics import classification_report, confusion_matrix

from sklearn.model_selection import GridSearchCV

from sklearn.pipeline import Pipeline

from sklearn.preprocessing import StandardScaler

from sklearn.svm import SVC

import pandas as pd

import pandas as pd

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

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

sex_and_embark_train = pd.get_dummies(train[['Sex', 'Embarked']])
sex_and_embark_test = pd.get_dummies(test[['Sex', 'Embarked']])

train = train.drop(['Sex', 'Embarked'], axis=1)
test = test.drop(['Sex', 'Embarked'], axis=1)

train = train.join(sex_and_embark_train)
test = test.join(sex_and_embark_test)

train.fillna(train.mean(), inplace=True)

test.fillna(test.mean(), inplace=True)

X_train = train.drop(['Survived', 'Name', 'Ticket', 'Cabin'], axis=1)
y_train = train['Survived']

X_test = test.drop(['Name', 'Ticket', 'Cabin'], axis=1)
y_test = gender_submission['Survived']

steps = [('scaler', StandardScaler()), ('SVM', SVC())]
pipeline = Pipeline(steps)
parameters = {'SVM__C': [1, 10, 100], 'SVM__gamma': [0.1, 0.01]}
cv = GridSearchCV(pipeline, parameters, cv=3)
cv.fit(X_train, y_train)
y_pred = cv.predict(X_test)

my_submission = pd.DataFrame({'PassengerId': X_test.PassengerId, 'Survived': y_pred})

my_submission