<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Embarked feature
Step1:  Sex feature
First, let's have a look at which gender is dominant in the population by a countplot.
Step2:  According to sex vs. survived chart, most of men did not survived while the majority of women did. The following chart also supports this claim by showing us that 70% of women survived.
Step3:  The inference is that this sex feature can be used in a classification task to determine whether a given person survived or not.
Pclass feature
This stands for Passenger Class. There are three classes as 1 = 1st; 2 = 2nd; 3 = 3rd. We can make a guess saying most probably the first class passengers survived thanks to their nobility. This guess is based on the domain knowledge; in that time classes among the people is more obvious and severe than now. Let's have a look at the data to see the truth.
Step4:  The chart above corrects the guess
<ASSISTANT_TASK:>
Python Code:
sns.countplot(data=df, hue="Survived", x="Embarked")
sns.barplot(data=df, x="Embarked", y="Survived")
sns.countplot(data=df, x="Age")
sns.boxplot(data=df, x="Survived", y="Age")
sns.stripplot(
    x="Survived", y="Age", data=df, jitter=True, edgecolor="gray", alpha=0.25)
sns.FacetGrid(df, hue="Survived", size=6).map(sns.kdeplot, "Age").add_legend()
Explanation: Embarked feature
End of explanation
sns.countplot(data=df, x="Sex")
sns.countplot(data=df, hue="Survived", x="Sex")
Explanation: Sex feature
First, let's have a look at which gender is dominant in the population by a countplot.
End of explanation
sns.barplot(data=df, x="Sex", y="Survived")
Explanation: According to sex vs. survived chart, most of men did not survived while the majority of women did. The following chart also supports this claim by showing us that 70% of women survived.
End of explanation
sns.countplot(data=df, hue="Survived", x="Pclass")
sns.countplot(data=df[df['Pclass'] == 1], hue="Survived", x="Sex")
Explanation: The inference is that this sex feature can be used in a classification task to determine whether a given person survived or not.
Pclass feature
This stands for Passenger Class. There are three classes as 1 = 1st; 2 = 2nd; 3 = 3rd. We can make a guess saying most probably the first class passengers survived thanks to their nobility. This guess is based on the domain knowledge; in that time classes among the people is more obvious and severe than now. Let's have a look at the data to see the truth.
End of explanation
sns.countplot(data=df[df['Pclass'] == 3], hue="Survived", x="Sex")
sns.barplot(x="Sex", y="Survived", hue="Pclass", data=df);
def titanicFit(df):
    X = df[["Sex", "Age", "Pclass", "Embarked"]]
    y = df["Survived"]
    X.Age.fillna(X.Age.mean(), inplace=True)
    X.Sex.replace(to_replace="male", value=1, inplace=True)
    X.Sex.replace(to_replace="female", value=0, inplace=True)
    X.Embarked.replace(to_replace="S", value=1, inplace=True)
    X.Embarked.replace(to_replace="C", value=2, inplace=True)
    X.Embarked.replace(to_replace="Q", value=3, inplace=True)
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(
            X, y, test_size=0.3, random_state=0)
    clf = svm.SVC(kernel="rbf")
    parameters = [
        {
            "kernel" :["linear"]
        }, {
            "kernel" :["rbf"], "C":[1, 10, 100], "gamma":[0.001, 0.002, 0.01]}
        ]
    clf = grid_search.GridSearchCV(
        svm.SVC(), param_grid=parameters, cv=5).fit(X, y)
    return clf
    #print clf.score(X_test, y_test)
clf = titanicFit(df[df.Embarked.isnull() == False])
clf.grid_scores_
Explanation: The chart above corrects the guess: unfortunatelly, passenger class plays a crucial role.
End of explanation
<END_TASK>