| title: “PHAN TRINH BAY” |
| author: “VO DUC DUY” |
| date: “2025-10-31” |
| output: html_document |
library(caret) library(dplyr)
df <- read.csv(“concrete.csv”)
df <- df %>% mutate( wc_ratio = water / cement, # strength_class = 1 nếu cường độ >= 30 Mpa, 0 nếu ngược lại strength_class = ifelse(strength >= 30, 1, 0) )
df\(strength_class <- factor(df\)strength_class, levels = c(0, 1))
set.seed(42) # Phân chia dữ liệu dựa trên biến mục tiêu (stratified sampling) trainIndex <- createDataPartition(df$strength_class, p = 0.7, list = FALSE) train_data <- df[trainIndex, ] test_data <- df[-trainIndex, ]
model_1 <- glm(strength_class ~ slag + ash + superplastic + coarseagg + fineagg + age + wc_ratio, data = train_data, family = binomial(link = “logit”))
summary(model_1)
save(model_1, train_data, test_data, file = “logistic_model_data.RData”)
print(“Đã tạo model_1 và lưu các objects cần thiết vào file logistic_model_data.RData”)