1. Introduction to Scikit-Learn
Activity 1.01: Selecting a Target Feature and Creating a Target Matrix
Solution:
- Load the
titanic
dataset using theseaborn
library:import seaborn as sns titanic = sns.load_dataset('titanic') titanic.head(10)
The first couple of rows should look as follows:
- Select your preferred target feature for the goal of this activity.
The preferred target feature could be either
survived
oralive
. This is mainly because both of them label whether a person survived the crash. For the following steps, the variable that's been chosen issurvived
. However, choosingalive
will not affect the final shape of the variables. - Create both the features matrix and the target matrix. Make sure that you store the data from the features matrix in a variable, X, and the data from the target matrix in another variable, Y:
X = titanic.drop('survived',axis = 1) Y = titanic...