Xử lý dữ liệu khuyết bằng Imputation trong R
Michal Oleszak
Machine Learning Engineer

Hầu hết mô hình thống kê ước lượng phân phối có điều kiện của biến phản hồi:
$p(y|X)$
Để tạo một dự đoán đơn, ta tóm tắt phân phối này:
Thay vào đó, có thể lấy mẫu từ các phân phối này để tăng độ biến thiên.


Nhiệm vụ: bù PhysActive từ dữ liệu nhanes bằng hồi quy logistic.
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
Nhiệm vụ: bù PhysActive từ dữ liệu nhanes bằng hồi quy logistic.
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
logreg_model <- glm(PhysActive ~ Age + Weight + Pulse,
data = nhanes_imp, family = binomial)
Nhiệm vụ: bù PhysActive từ dữ liệu nhanes bằng hồi quy logistic.
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
logreg_model <- glm(PhysActive ~ Age + Weight + Pulse,
data = nhanes_imp, family = binomial)
preds <- predict(logreg_model, type = "response")
Nhiệm vụ: bù PhysActive từ dữ liệu nhanes bằng hồi quy logistic.
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
logreg_model <- glm(PhysActive ~ Age + Weight + Pulse,
data = nhanes_imp, family = binomial)
preds <- predict(logreg_model, type = "response")
preds <- ifelse(preds >= 0.5, 1, 0)
Nhiệm vụ: bù PhysActive từ dữ liệu nhanes bằng hồi quy logistic.
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
logreg_model <- glm(PhysActive ~ Age + Weight + Pulse,
data = nhanes_imp, family = binomial)
preds <- predict(logreg_model, type = "response")
preds <- ifelse(preds >= 0.5, 1, 0)
nhanes_imp[missing_physactive, "PhysActive"] <- preds[missing_physactive]
Độ biến thiên của dữ liệu đã bù:
table(preds[missing_physactive])
1
26
Độ biến thiên của dữ liệu PhysActive quan sát:
table(nhanes$PhysActive)
0 1
181 610
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
logreg_model <- glm(PhysActive ~ Age + Weight + Pulse,
data = nhanes_imp, family = binomial)
preds <- predict(logreg_model, type = "response")
preds <- ifelse(preds >= 0.5, 1, 0)
nhanes_imp[missing_physactive, "PhysActive"] <- preds[missing_physactive]
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
logreg_model <- glm(PhysActive ~ Age + Weight + Pulse,
data = nhanes_imp, family = binomial)
preds <- predict(logreg_model, type = "response")
nhanes_imp[missing_physactive, "PhysActive"] <- preds[missing_physactive]
nhanes_imp <- hotdeck(nhanes)
missing_physactive <- is.na(nhanes$PhysActive)
logreg_model <- glm(PhysActive ~ Age + Weight + Pulse,
data = nhanes_imp, family = binomial)
preds <- predict(logreg_model, type = "response")
preds <- rbinom(length(preds), size = 1, prob = preds)
nhanes_imp[missing_physactive, "PhysActive"] <- preds[missing_physactive]
Độ biến thiên của dữ liệu đã bù:
table(preds[missing_physactive])
0 1
5 21
Độ biến thiên của dữ liệu PhysActive quan sát:
table(nhanes$PhysActive)
0 1
181 610
Xử lý dữ liệu khuyết bằng Imputation trong R