
UnsplashのMohammad Ebeshが撮影した写真のMohammad Ebeshが撮影したイラスト素材
This post is contuniuation of above post.
Starting with this session, we'll be working on machine learning. First, we'll split the data into training data and test data.
First, let's load 'tidymodels' package.

I use initial_split(), training() and testing() to make training data set and test data set.

I will check whether there is a difference between the gap in the training data and the gap in the test data. I use t.test().

p-value is 0.7845. So, there is not statistically significant difference between test data's gap and training data's gap.
Also, let's make boxplot.


There is no difference between training(green) and testing(pink).
That's it. Thank you!
next post is
To read from the 1st post,
Today code is following below.
#
# load tidymodels package
library(tidymodels)
#
# data split
set.seed(253)
data_split <- initial_split(df, prop = 3/4)
train_data <- training(data_split)
test_data <- testing(data_split)
#
# check gap
t.test(train_data$gap, test_data$gap)
#
# Boxplot
bind_rows(
tibble(
data = "training",
gap = train_data$gap
),
tibble(
data = "testing",
gap = test_data$gap
)
) |>
ggplot(aes(x = data, y = gap, group = data)) +
geom_boxplot(aes(fill = data)) +
theme_minimal()
#