March 2017
Beginner to intermediate
1065 pages
27h 7m
English
For this example of working with Naïve Bayes in R, we are going to use the Titanic dataset. The classification problem we have is to know whether or not individuals died in the Titanic accident. We will create a training dataset and a testing dataset (in order to test how well the classifier performs).
The first thing we need to know is how to convert the Titanic dataset (of class table) to a data frame:
1 Titanic.df_weighted = data.frame(Titanic)
Let's have a look at the dataset:
|
Class |
Sex |
Age |
Survived |
Freq | |
|---|---|---|---|---|---|
|
1 |
1st |
Male |
Child |
No |
0 |
|
2 |
2nd |
Male |
Child |
No |
0 |
|
3 |
3rd |
Male |
Child |
No |
35 |
|
4 |
Crew |
Male |
Child |
No |
0 |
|
5 |
1st |
Female |
Child |
No |
0 |
Read now
Unlock full access