Bu bölmədə CAT simulyasiya nəticələrinin vizual təhlili üçün hərtərəfli qrafik funksiyalar sistemi yaradacağıq. Vizual analiz CAT sistemlərinin performansını anlamaq və nəticələri effektiv şəkildə təqdim etmək üçün əsasdır.
Vizual analiz aşağıdakı məqsədlərə xidmət edir:
# Test məlumatları yaratmaq üçün funksiya
generate_sample_data <- function(n_subjects = 100, seed = 12345) {
set.seed(seed)
# Simulate CAT results
true_theta <- rnorm(n_subjects, 0, 1)
estimation_error <- abs(rnorm(n_subjects, 0, 0.3))
estimated_theta <- true_theta + rnorm(n_subjects, 0, estimation_error)
standard_error <- runif(n_subjects, 0.2, 0.5)
items_administered <- sample(5:30, n_subjects, replace = TRUE)
bias <- estimated_theta - true_theta
# Derived variables
ability_group <- cut(true_theta,
breaks = c(-Inf, -1, 0, 1, Inf),
labels = c("Aşağı", "Orta-Aşağı", "Orta-Yuxarı", "Yuxarı"))
precision_met <- standard_error <= 0.3
efficiency <- 1 / (standard_error * items_administered)
results_df <- data.frame(
examinee_id = 1:n_subjects,
true_theta = true_theta,
estimated_theta = estimated_theta,
estimation_error = estimation_error,
standard_error = standard_error,
items_administered = items_administered,
bias = bias,
ability_group = ability_group,
precision_met = precision_met,
efficiency = efficiency
)
return(results_df)
}
# Sample data yaratmaq
results_summary <- generate_sample_data(100)
cat("=== TEST MƏLUMATLARI HAZIRLANDI ===\n")
## === TEST MƏLUMATLARI HAZIRLANDI ===
## Test alıcı sayı: 100
## Dəyişən sayı: 10
## Həqiqi θ aralığı: -2.38 2.48
## Qiymətləndirmə xətası aralığı: 0.004 0.797
## Test uzunluğu aralığı: 5 30
# 1. Həqiqi vs Qiymətləndirilmiş qabiliyyət scatter plot
plot_accuracy <- function(results_df, interactive = FALSE) {
# Correlation hesablama
correlation <- cor(results_df$true_theta, results_df$estimated_theta)
r_squared <- correlation^2
p <- ggplot(results_df, aes(x = true_theta, y = estimated_theta)) +
geom_point(aes(color = ability_group), alpha = 0.7, size = 2.5) +
geom_abline(slope = 1, intercept = 0, color = "red", linetype = "dashed", size = 1.2) +
geom_smooth(method = "lm", se = TRUE, color = "blue", alpha = 0.3) +
labs(title = "Həqiqi vs Qiymətləndirilmiş Qabiliyyət",
subtitle = paste("r =", round(correlation, 3), " | R² =", round(r_squared, 3)),
x = "Həqiqi Qabiliyyət (θ)",
y = "Qiymətləndirilmiş Qabiliyyət (θ̂)",
color = "Qabiliyyət Qrupu") +
theme_minimal() +
theme(legend.position = "bottom") +
coord_equal() +
scale_color_viridis_d() +
annotate("text", x = min(results_df$true_theta), y = max(results_df$estimated_theta),
label = "Mükəmməl xətt", color = "red", hjust = 0, vjust = 1)
if (interactive) {
return(ggplotly(p))
} else {
return(p)
}
}
# 2. Qiymətləndirmə xətasının paylanması
plot_error_distribution <- function(results_df, by_group = FALSE) {
mae <- mean(results_df$estimation_error)
rmse <- sqrt(mean(results_df$estimation_error^2))
if (by_group) {
p <- ggplot(results_df, aes(x = estimation_error, fill = ability_group)) +
geom_histogram(bins = 20, alpha = 0.7, color = "black", position = "identity") +
facet_wrap(~ ability_group, scales = "free_y") +
scale_fill_viridis_d()
} else {
p <- ggplot(results_df, aes(x = estimation_error)) +
geom_histogram(bins = 25, fill = "lightcoral", alpha = 0.8, color = "black") +
geom_density(aes(y = ..scaled..*max(..count..)), alpha = 0.3, fill = "blue")
}
p <- p +
labs(title = "Qiymətləndirmə Xətasının Paylanması",
subtitle = paste("MAE =", round(mae, 3), " | RMSE =", round(rmse, 3)),
x = "Mütləq Qiymətləndirmə Xətası",
y = "Tezlik") +
theme_minimal() +
geom_vline(xintercept = mae, color = "red", linetype = "dashed", size = 1.2) +
annotate("text", x = mae + 0.05, y = Inf,
label = paste("MAE =", round(mae, 3)),
color = "red", hjust = 0, vjust = 1.2)
if (!by_group) {
p <- p + theme(legend.position = "none")
}
return(p)
}
# 3. Tapşırıq sayının paylanması
plot_items_distribution <- function(results_df, overlay_stats = TRUE) {
mean_items <- mean(results_df$items_administered)
median_items <- median(results_df$items_administered)
p <- ggplot(results_df, aes(x = items_administered)) +
geom_histogram(bins = 20, fill = "lightgreen", alpha = 0.8, color = "black") +
labs(title = "İstifadə Edilən Tapşırıq Sayının Paylanması",
subtitle = paste("Orta =", round(mean_items, 1), " | Median =", median_items),
x = "Tapşırıq Sayı",
y = "Tezlik") +
theme_minimal()
if (overlay_stats) {
p <- p +
geom_vline(xintercept = mean_items, color = "red", linetype = "dashed", size = 1.2) +
geom_vline(xintercept = median_items, color = "blue", linetype = "dotted", size = 1.2) +
annotate("text", x = mean_items + 1, y = Inf,
label = "Orta", color = "red", hjust = 0, vjust = 1.2) +
annotate("text", x = median_items + 1, y = Inf,
label = "Median", color = "blue", hjust = 0, vjust = 2.4)
}
return(p)
}
# 4. SE vs Tapşırıq sayı əlaqəsi
plot_se_vs_items <- function(results_df, add_threshold = TRUE) {
correlation <- cor(results_df$items_administered, results_df$standard_error)
p <- ggplot(results_df, aes(x = items_administered, y = standard_error)) +
geom_point(aes(color = ability_group), alpha = 0.7, size = 2.5) +
geom_smooth(method = "loess", se = TRUE, color = "red", alpha = 0.3) +
labs(title = "Standart Xəta vs Tapşırıq Sayı",
subtitle = paste("Korrelyasiya r =", round(correlation, 3)),
x = "Tapşırıq Sayı",
y = "Standart Xəta",
color = "Qabiliyyət Qrupu") +
theme_minimal() +
theme(legend.position = "bottom") +
scale_color_viridis_d()
if (add_threshold) {
p <- p +
geom_hline(yintercept = 0.3, color = "orange", linetype = "dashed", size = 1.2) +
annotate("text", x = max(results_df$items_administered), y = 0.32,
label = "SE Threshold = 0.3", color = "orange", hjust = 1, vjust = 0)
}
return(p)
}
# Əsas qrafiklərın göstərilməsi
cat("=== ƏSAS VİZUAL ANALİZ QRAFİKLƏRİ ===\n\n")
## === ƏSAS VİZUAL ANALİZ QRAFİKLƏRİ ===
# Basic plots
p1 <- plot_accuracy(results_summary)
p2 <- plot_error_distribution(results_summary)
p3 <- plot_items_distribution(results_summary)
p4 <- plot_se_vs_items(results_summary)
# İlk dəst qrafiklər
grid.arrange(p1, p2, ncol = 2)
# Group-wise error distribution
p2_group <- plot_error_distribution(results_summary, by_group = TRUE)
print(p2_group)
# 5. Comprehensive performance dashboard
create_performance_dashboard <- function(results_df) {
# Calculate summary statistics
summary_stats <- results_df %>%
summarise(
n = n(),
mean_items = round(mean(items_administered), 1),
rmse = round(sqrt(mean(estimation_error^2)), 3),
correlation = round(cor(true_theta, estimated_theta), 3),
precision_rate = round(mean(precision_met) * 100, 1)
)
# Main scatter plot
p1 <- ggplot(results_df, aes(x = true_theta, y = estimated_theta)) +
geom_point(aes(color = standard_error, size = items_administered), alpha = 0.7) +
geom_abline(slope = 1, intercept = 0, color = "red", linetype = "dashed") +
scale_color_gradient2(low = "green", mid = "yellow", high = "red",
midpoint = 0.3, name = "SE") +
scale_size_continuous(range = c(1, 4), name = "Items") +
labs(title = "CAT Performance Dashboard",
subtitle = paste("n =", summary_stats$n, "| RMSE =", summary_stats$rmse,
"| r =", summary_stats$correlation),
x = "Həqiqi θ", y = "Qiymətləndirilmiş θ") +
theme_minimal() +
coord_equal()
# Error by ability
p2 <- ggplot(results_df, aes(x = ability_group, y = estimation_error, fill = ability_group)) +
geom_boxplot(alpha = 0.7) +
geom_jitter(width = 0.2, alpha = 0.4) +
scale_fill_viridis_d() +
labs(title = "Xəta vs Qabiliyyət Qrupu", x = "Qrup", y = "Xəta") +
theme_minimal() +
theme(legend.position = "none")
# Precision achievement
precision_summary <- results_df %>%
group_by(ability_group) %>%
summarise(precision_rate = mean(precision_met) * 100, .groups = 'drop')
p3 <- ggplot(precision_summary, aes(x = ability_group, y = precision_rate, fill = ability_group)) +
geom_col(alpha = 0.8) +
geom_text(aes(label = paste0(round(precision_rate, 1), "%")),
vjust = -0.5, size = 3) +
scale_fill_viridis_d() +
labs(title = "Precision Achievement", x = "Qrup", y = "Rate (%)") +
theme_minimal() +
theme(legend.position = "none") +
ylim(0, 110)
# Test length distribution
p4 <- ggplot(results_df, aes(x = items_administered, fill = precision_met)) +
geom_histogram(bins = 15, alpha = 0.7, position = "stack") +
scale_fill_manual(values = c("red", "green"),
labels = c("SE > 0.3", "SE ≤ 0.3"),
name = "Precision") +
labs(title = "Test Uzunluğu vs Precision", x = "Items", y = "Count") +
theme_minimal()
return(list(p1 = p1, p2 = p2, p3 = p3, p4 = p4))
}
# 6. Bias analysis visualization
plot_bias_analysis <- function(results_df) {
# Bias by true theta
p1 <- ggplot(results_df, aes(x = true_theta, y = bias)) +
geom_point(alpha = 0.6, color = "darkred") +
geom_hline(yintercept = 0, linetype = "dashed", color = "black") +
geom_smooth(method = "loess", se = TRUE, color = "blue") +
labs(title = "Bias Pattern Analysis",
subtitle = paste("Orta Bias =", round(mean(results_df$bias), 3)),
x = "Həqiqi θ", y = "Bias (θ̂ - θ)") +
theme_minimal()
# Bias distribution
p2 <- ggplot(results_df, aes(x = bias)) +
geom_histogram(bins = 25, fill = "lightblue", alpha = 0.7, color = "black") +
geom_vline(xintercept = 0, color = "red", linetype = "dashed") +
geom_vline(xintercept = mean(results_df$bias), color = "blue", linetype = "dashed") +
labs(title = "Bias Paylanması", x = "Bias", y = "Tezlik") +
theme_minimal()
return(list(bias_pattern = p1, bias_distribution = p2))
}
# 7. Efficiency analysis
plot_efficiency_analysis <- function(results_df) {
# Efficiency vs ability
p1 <- ggplot(results_df, aes(x = true_theta, y = efficiency)) +
geom_point(aes(color = ability_group), alpha = 0.7, size = 2) +
geom_smooth(method = "loess", se = TRUE, color = "red") +
scale_color_viridis_d() +
labs(title = "Test Effektivliyi vs Qabiliyyət",
x = "Həqiqi θ", y = "Effektivlik (1/SE×Items)",
color = "Qrup") +
theme_minimal()
# Efficiency distribution by group
p2 <- ggplot(results_df, aes(x = ability_group, y = efficiency, fill = ability_group)) +
geom_violin(alpha = 0.7) +
geom_boxplot(width = 0.2, alpha = 0.5) +
scale_fill_viridis_d() +
labs(title = "Effektivlik Paylanması", x = "Qrup", y = "Effektivlik") +
theme_minimal() +
theme(legend.position = "none")
return(list(efficiency_trend = p1, efficiency_distribution = p2))
}
# İrəliləmiş qrafiklər
dashboard <- create_performance_dashboard(results_summary)
bias_plots <- plot_bias_analysis(results_summary)
efficiency_plots <- plot_efficiency_analysis(results_summary)
# Dashboard göstərimi
grid.arrange(dashboard$p1, dashboard$p2, dashboard$p3, dashboard$p4, ncol = 2)
# Bias və efficiency analizi
grid.arrange(bias_plots$bias_pattern, bias_plots$bias_distribution, ncol = 2)
# 8. Interactive scatter plot
create_interactive_scatter <- function(results_df, save_html = FALSE) {
# Əlavə məlumat tooltips üçün
results_df$tooltip_text <- paste(
"ID:", results_df$examinee_id,
"<br>Həqiqi θ:", round(results_df$true_theta, 3),
"<br>Qiymətləndirilmiş θ:", round(results_df$estimated_theta, 3),
"<br>Xəta:", round(results_df$estimation_error, 3),
"<br>SE:", round(results_df$standard_error, 3),
"<br>Items:", results_df$items_administered
)
p <- ggplot(results_df, aes(x = true_theta, y = estimated_theta,
text = tooltip_text, color = ability_group)) +
geom_point(alpha = 0.7, size = 2) +
geom_abline(slope = 1, intercept = 0, color = "red", linetype = "dashed") +
labs(title = "İnteraktiv CAT Performans Analizi",
x = "Həqiqi θ", y = "Qiymətləndirilmiş θ",
color = "Qabiliyyət Qrupu") +
theme_minimal() +
scale_color_viridis_d()
interactive_plot <- ggplotly(p, tooltip = "text")
if (save_html) {
# Faylı saxlamaq üçün (real implementasiyada)
cat("İnteraktiv qrafik 'interactive_cat_analysis.html' faylında saxlanacaq\n")
}
return(interactive_plot)
}
# 9. Correlation matrix visualization
plot_correlation_matrix <- function(results_df) {
# Numeric dəyişənləri seçmək
numeric_vars <- results_df %>%
select(true_theta, estimated_theta, estimation_error,
standard_error, items_administered, efficiency) %>%
rename(
"Həqiqi θ" = true_theta,
"Qiymətləndirməli θ" = estimated_theta,
"Xəta" = estimation_error,
"SE" = standard_error,
"Items" = items_administered,
"Effektivlik" = efficiency
)
# Correlation matrix
cor_matrix <- cor(numeric_vars)
# Custom correlation plot
corrplot(cor_matrix,
method = "circle",
type = "upper",
order = "hclust",
tl.cex = 0.8,
tl.col = "black",
cl.ratio = 0.2,
addCoef.col = "black",
number.cex = 0.7,
title = "Dəyişənlər Arasında Korrelyasiya",
mar = c(0,0,1,0))
return(cor_matrix)
}
# 10. Multi-panel summary plot
create_summary_multipanel <- function(results_df) {
# Hazırlıq
results_long <- results_df %>%
select(examinee_id, true_theta, estimated_theta, estimation_error,
standard_error, items_administered) %>%
pivot_longer(cols = c(estimation_error, standard_error, items_administered),
names_to = "metric", values_to = "value")
results_long$metric <- factor(results_long$metric,
levels = c("estimation_error", "standard_error", "items_administered"),
labels = c("Qiymətləndirmə Xətası", "Standart Xəta", "Test Uzunluğu"))
# Multi-panel plot
p <- ggplot(results_long, aes(x = true_theta, y = value)) +
geom_point(alpha = 0.6, color = "steelblue") +
geom_smooth(method = "loess", se = TRUE, color = "red") +
facet_wrap(~ metric, scales = "free_y", ncol = 3) +
labs(title = "CAT Metrics vs Həqiqi Qabiliyyət",
x = "Həqiqi θ", y = "Dəyər") +
theme_minimal() +
theme(strip.text = element_text(size = 10, face = "bold"))
return(p)
}
# İnteraktiv və multipanel qrafiklər
cat("İnteraktiv və ətraflı qrafiklər yaradılır...\n\n")
## İnteraktiv və ətraflı qrafiklər yaradılır...
# Interactive scatter (static version for demo)
# interactive_scatter <- create_interactive_scatter(results_summary)
# print(interactive_scatter)
# Correlation matrix
correlation_matrix <- plot_correlation_matrix(results_summary)
# Multi-panel summary
multipanel_plot <- create_summary_multipanel(results_summary)
print(multipanel_plot)
# 11. Convergence analysis visualization (simulated)
plot_convergence_analysis <- function(results_df, n_subjects = 5) {
# Simulated convergence data
convergence_data <- data.frame()
for (i in 1:n_subjects) {
subject_data <- results_df[i, ]
n_steps <- subject_data$items_administered
# Simulate theta progression
theta_progression <- cumsum(rnorm(n_steps, 0, 0.1)) + subject_data$true_theta
se_progression <- 1 / sqrt(1:n_steps)
temp_data <- data.frame(
Subject = paste("Test alıcısı", i),
Step = 1:n_steps,
Theta_Est = theta_progression,
SE = se_progression,
True_Theta = subject_data$true_theta
)
convergence_data <- rbind(convergence_data, temp_data)
}
# Theta convergence
p1 <- ggplot(convergence_data, aes(x = Step, y = Theta_Est, color = Subject)) +
geom_line(size = 1.2, alpha = 0.8) +
geom_point(size = 2, alpha = 0.6) +
facet_wrap(~ Subject, scales = "free_y") +
geom_hline(aes(yintercept = True_Theta), linetype = "dashed", color = "red") +
labs(title = "Theta Konvergensiyası",
x = "Test Addımı", y = "Qiymətləndirilmiş θ") +
theme_minimal() +
theme(legend.position = "none")
# SE progression
p2 <- ggplot(convergence_data, aes(x = Step, y = SE, color = Subject)) +
geom_line(size = 1.2, alpha = 0.8) +
geom_point(size = 2, alpha = 0.6) +
geom_hline(yintercept = 0.3, linetype = "dashed", color = "orange") +
labs(title = "Standart Xəta Azalması",
x = "Test Addımı", y = "SE") +
theme_minimal() +
scale_color_viridis_d()
return(list(theta_convergence = p1, se_progression = p2))
}
# 12. Item usage heatmap (simulated)
plot_item_usage_heatmap <- function(results_df, n_items = 50) {
# Simulate item usage data
set.seed(123)
item_usage_matrix <- matrix(0, nrow = nrow(results_df), ncol = n_items)
for (i in 1:nrow(results_df)) {
n_used <- results_df$items_administered[i]
used_items <- sample(1:n_items, n_used)
item_usage_matrix[i, used_items] <- 1
}
# Convert to long format
item_usage_long <- expand.grid(
Subject = 1:nrow(results_df),
Item = 1:n_items
)
item_usage_long$Used <- as.vector(item_usage_matrix)
# Calculate item usage frequency
item_freq <- colSums(item_usage_matrix)
top_items <- order(item_freq, decreasing = TRUE)[1:20]
# Filter for top used items and subset of subjects
subset_data <- item_usage_long %>%
filter(Item %in% top_items, Subject <= 20)
p <- ggplot(subset_data, aes(x = factor(Item), y = factor(Subject), fill = factor(Used))) +
geom_tile(color = "white") +
scale_fill_manual(values = c("0" = "white", "1" = "steelblue"),
labels = c("İstifadə edilməyib", "İstifadə edilib"),
name = "Status") +
labs(title = "Item İstifadə Pattern (İlk 20 test alıcısı, Ən çox istifadə edilən items)",
x = "Item ID", y = "Test Alıcısı ID") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
return(p)
}
# 13. Quality control charts
create_quality_control_charts <- function(results_df) {
# Moving average for monitoring
results_df$order <- 1:nrow(results_df)
window_size <- 10
# Calculate moving averages
moving_avg_error <- rep(NA, nrow(results_df))
moving_avg_se <- rep(NA, nrow(results_df))
for (i in window_size:nrow(results_df)) {
start_idx <- max(1, i - window_size + 1)
moving_avg_error[i] <- mean(results_df$estimation_error[start_idx:i])
moving_avg_se[i] <- mean(results_df$standard_error[start_idx:i])
}
results_df$moving_avg_error <- moving_avg_error
results_df$moving_avg_se <- moving_avg_se
# Error control chart
p1 <- ggplot(results_df, aes(x = order)) +
geom_point(aes(y = estimation_error), alpha = 0.5, color = "gray") +
geom_line(aes(y = moving_avg_error), color = "blue", size = 1.2) +
geom_hline(yintercept = mean(results_df$estimation_error, na.rm = TRUE),
color = "red", linetype = "dashed") +
geom_hline(yintercept = mean(results_df$estimation_error, na.rm = TRUE) +
2*sd(results_df$estimation_error, na.rm = TRUE),
color = "orange", linetype = "dotted") +
labs(title = "Qiymətləndirmə Xətası Nəzarət Qrafiki",
subtitle = paste("Hərəkətli orta (", window_size, "sınaq)"),
x = "Test Alıcısı Sıra Nömrəsi", y = "Qiymətləndirmə Xətası") +
theme_minimal()
# SE control chart
p2 <- ggplot(results_df, aes(x = order)) +
geom_point(aes(y = standard_error), alpha = 0.5, color = "gray") +
geom_line(aes(y = moving_avg_se), color = "green", size = 1.2) +
geom_hline(yintercept = 0.3, color = "red", linetype = "dashed") +
geom_hline(yintercept = mean(results_df$standard_error, na.rm = TRUE),
color = "blue", linetype = "dashed") +
labs(title = "Standart Xəta Nəzarət Qrafiki",
x = "Test Alıcısı Sıra Nömrəsi", y = "Standart Xəta") +
theme_minimal()
return(list(error_control = p1, se_control = p2))
}
# Specialized qrafiklər
convergence_plots <- plot_convergence_analysis(results_summary)
item_heatmap <- plot_item_usage_heatmap(results_summary)
qc_charts <- create_quality_control_charts(results_summary)
# Convergence analysis
grid.arrange(convergence_plots$theta_convergence, convergence_plots$se_progression, ncol = 1)
# 14. Executive dashboard
create_executive_dashboard <- function(results_df) {
# Calculate key metrics
key_metrics <- list(
n_subjects = nrow(results_df),
mean_items = round(mean(results_df$items_administered), 1),
rmse = round(sqrt(mean(results_df$estimation_error^2)), 3),
correlation = round(cor(results_df$true_theta, results_df$estimated_theta), 3),
precision_rate = round(mean(results_df$precision_met) * 100, 1),
efficiency = round(30 / mean(results_df$items_administered), 2)
)
# Create summary text plot
summary_text <- paste(
"CAT SİSTEMİ PERFORMANS XÜLASƏSİ\n\n",
"Test alıcı sayı: ", key_metrics$n_subjects, "\n",
"Orta test uzunluğu: ", key_metrics$mean_items, " item\n",
"RMSE: ", key_metrics$rmse, "\n",
"Validity (r): ", key_metrics$correlation, "\n",
"Precision rate: ", key_metrics$precision_rate, "%\n",
"Efficiency ratio: ", key_metrics$efficiency, "\n\n",
"STATUS: ",
ifelse(key_metrics$rmse < 0.4 & key_metrics$correlation > 0.8,
"✅ ƏLA PERFORMANS", "⚠️ TƏKMİLLƏŞDİRMƏ LAZIM")
)
# Text plot
p_text <- ggplot() +
annotate("text", x = 0.5, y = 0.5, label = summary_text,
size = 4, hjust = 0.5, vjust = 0.5, family = "mono") +
theme_void() +
labs(title = "İcra Xülasəsi")
# Performance gauge (simulated with bar chart)
performance_data <- data.frame(
Metric = c("Validity", "Precision", "Efficiency", "Overall"),
Score = c(
min(key_metrics$correlation * 100, 100),
key_metrics$precision_rate,
min(key_metrics$efficiency * 50, 100),
NA
)
)
performance_data$Score[4] <- mean(performance_data$Score[1:3], na.rm = TRUE)
p_gauge <- ggplot(performance_data, aes(x = Metric, y = Score, fill = Metric)) +
geom_col(alpha = 0.8) +
geom_text(aes(label = paste0(round(Score, 1), "%")),
vjust = -0.5, size = 3) +
coord_cartesian(ylim = c(0, 110)) +
scale_fill_viridis_d() +
labs(title = "Performans Skorları", y = "Skor (%)", x = "") +
theme_minimal() +
theme(legend.position = "none")
# Trend analysis
results_df$batch <- cut(1:nrow(results_df), breaks = 5, labels = 1:5)
trend_data <- results_df %>%
group_by(batch) %>%
summarise(
Mean_Error = mean(estimation_error),
Mean_SE = mean(standard_error),
Mean_Items = mean(items_administered),
.groups = 'drop'
)
trend_long <- trend_data %>%
pivot_longer(cols = c(Mean_Error, Mean_SE, Mean_Items),
names_to = "Metric", values_to = "Value") %>%
mutate(Metric = recode(Metric,
"Mean_Error" = "Orta Xəta",
"Mean_SE" = "Orta SE",
"Mean_Items" = "Orta Items"))
p_trend <- ggplot(trend_long, aes(x = batch, y = Value, color = Metric, group = Metric)) +
geom_line(size = 1.2) +
geom_point(size = 3) +
facet_wrap(~ Metric, scales = "free_y") +
scale_color_viridis_d() +
labs(title = "Performans Trendi", x = "Batch", y = "Dəyər") +
theme_minimal() +
theme(legend.position = "none")
return(list(
summary = p_text,
performance = p_gauge,
trend = p_trend,
metrics = key_metrics
))
}
# 15. Comprehensive comparison plot
create_comparison_plot <- function(results_df, scenarios = NULL) {
if (is.null(scenarios)) {
# Create simulated comparison scenarios
scenarios <- list(
"Current" = results_df,
"Scenario A" = results_df %>%
mutate(standard_error = standard_error * 0.9,
items_administered = items_administered + 2),
"Scenario B" = results_df %>%
mutate(standard_error = standard_error * 1.1,
items_administered = items_administered - 1)
)
}
# Combine scenarios
comparison_data <- data.frame()
for (i in 1:length(scenarios)) {
scenario_name <- names(scenarios)[i]
scenario_data <- scenarios[[i]]
scenario_data$Scenario <- scenario_name
comparison_data <- rbind(comparison_data, scenario_data)
}
# Summary comparison
scenario_summary <- comparison_data %>%
group_by(Scenario) %>%
summarise(
Mean_Items = mean(items_administered),
Mean_SE = mean(standard_error),
RMSE = sqrt(mean(estimation_error^2)),
Precision_Rate = mean(precision_met) * 100,
.groups = 'drop'
)
# Comparison plots
p1 <- ggplot(scenario_summary, aes(x = Scenario, y = Mean_Items, fill = Scenario)) +
geom_col(alpha = 0.8) +
geom_text(aes(label = round(Mean_Items, 1)), vjust = -0.5) +
scale_fill_viridis_d() +
labs(title = "Orta Test Uzunluğu", y = "Items") +
theme_minimal() +
theme(legend.position = "none")
p2 <- ggplot(scenario_summary, aes(x = Scenario, y = Mean_SE, fill = Scenario)) +
geom_col(alpha = 0.8) +
geom_text(aes(label = round(Mean_SE, 3)), vjust = -0.5) +
geom_hline(yintercept = 0.3, color = "red", linetype = "dashed") +
scale_fill_viridis_d() +
labs(title = "Orta SE", y = "Standard Error") +
theme_minimal() +
theme(legend.position = "none")
p3 <- ggplot(scenario_summary, aes(x = Scenario, y = RMSE, fill = Scenario)) +
geom_col(alpha = 0.8) +
geom_text(aes(label = round(RMSE, 3)), vjust = -0.5) +
scale_fill_viridis_d() +
labs(title = "RMSE", y = "Root Mean Square Error") +
theme_minimal() +
theme(legend.position = "none")
p4 <- ggplot(scenario_summary, aes(x = Scenario, y = Precision_Rate, fill = Scenario)) +
geom_col(alpha = 0.8) +
geom_text(aes(label = paste0(round(Precision_Rate, 1), "%")), vjust = -0.5) +
scale_fill_viridis_d() +
labs(title = "Precision Rate", y = "Rate (%)") +
theme_minimal() +
theme(legend.position = "none")
return(list(p1 = p1, p2 = p2, p3 = p3, p4 = p4, summary = scenario_summary))
}
# Executive dashboard
executive_dash <- create_executive_dashboard(results_summary)
comparison_plots <- create_comparison_plot(results_summary)
# Executive dashboard göstərimi
grid.arrange(executive_dash$summary, executive_dash$performance, ncol = 2)
# Comparison plots
grid.arrange(comparison_plots$p1, comparison_plots$p2,
comparison_plots$p3, comparison_plots$p4, ncol = 2)
# 16. Export functions for different formats
export_visualizations <- function(plot_list, output_dir = "cat_visualizations",
formats = c("png", "pdf", "svg")) {
cat("=== VİZUALLAşDIRMA EKSPORTu ===\n\n")
cat("Export directory:", output_dir, "\n")
cat("Export formatları:", paste(formats, collapse = ", "), "\n\n")
# Create directory (simulated)
cat("📁 Directory yaradılır...\n")
# Export each plot (simulated)
plot_names <- names(plot_list)
for (i in 1:length(plot_list)) {
plot_name <- ifelse(is.null(plot_names) || plot_names[i] == "",
paste0("plot_", i), plot_names[i])
for (format in formats) {
filename <- paste0(plot_name, ".", format)
cat("📊 Export edilir:", filename, "\n")
# Real implementasiyada:
# ggsave(filename = file.path(output_dir, filename),
# plot = plot_list[[i]],
# width = 10, height = 6, dpi = 300)
}
}
cat("\n✅ Bütün qrafiklər uğurla export edildi!\n\n")
# Create index file info
cat("📋 Index faylı yaradılır: visualization_index.html\n")
cat("🔗 Sharing link yaradılır: cat_analysis_report.html\n\n")
return(paste0(output_dir, "/visualization_index.html"))
}
# 17. Create presentation-ready plots
create_presentation_plots <- function(results_df, theme_type = "professional") {
cat("=== PRESENTASİYA QRAFİKLƏRİ ===\n\n")
# Custom theme
if (theme_type == "professional") {
custom_theme <- theme_minimal() +
theme(
plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5),
axis.title = element_text(size = 12, face = "bold"),
axis.text = element_text(size = 10),
legend.title = element_text(size = 11, face = "bold"),
legend.text = element_text(size = 10),
panel.grid.minor = element_blank(),
plot.background = element_rect(fill = "white", color = NA),
panel.background = element_rect(fill = "white", color = NA)
)
} else {
custom_theme <- theme_light()
}
# Key slides
slide1 <- ggplot(results_df, aes(x = true_theta, y = estimated_theta)) +
geom_point(aes(color = ability_group), alpha = 0.7, size = 3) +
geom_abline(slope = 1, intercept = 0, color = "red", linetype = "dashed", size = 1.5) +
scale_color_viridis_d() +
labs(title = "CAT Sistem Performansı",
subtitle = paste("Validity: r =", round(cor(results_df$true_theta, results_df$estimated_theta), 3)),
x = "Həqiqi Qabiliyyət", y = "Qiymətləndirilmiş Qabiliyyət",
color = "Qabiliyyət Qrupu") +
custom_theme +
coord_equal()
slide2 <- results_df %>%
group_by(ability_group) %>%
summarise(
Mean_Items = mean(items_administered),
Mean_SE = mean(standard_error),
Precision_Rate = mean(precision_met) * 100,
.groups = 'drop'
) %>%
pivot_longer(cols = c(Mean_Items, Mean_SE, Precision_Rate),
names_to = "Metric", values_to = "Value") %>%
mutate(Metric = recode(Metric,
"Mean_Items" = "Orta Test Uzunluğu",
"Mean_SE" = "Orta SE",
"Precision_Rate" = "Precision Rate (%)")) %>%
ggplot(aes(x = ability_group, y = Value, fill = ability_group)) +
geom_col(alpha = 0.8) +
facet_wrap(~ Metric, scales = "free_y") +
scale_fill_viridis_d() +
labs(title = "Qabiliyyət Qruplarına Görə Performans",
x = "Qabiliyyət Qrupu", y = "Dəyər",
fill = "Qrup") +
custom_theme +
theme(legend.position = "none")
slide3 <- ggplot(results_df, aes(x = items_administered, y = standard_error, color = precision_met)) +
geom_point(alpha = 0.7, size = 3) +
geom_hline(yintercept = 0.3, color = "red", linetype = "dashed", size = 1.2) +
scale_color_manual(values = c("red", "green"),
labels = c("SE > 0.3", "SE ≤ 0.3"),
name = "Precision Status") +
labs(title = "Effektivlik vs Precision",
subtitle = "Test uzunluğu və dəqiqlik arasında əlaqə",
x = "Test Uzunluğu", y = "Standart Xəta") +
custom_theme
cat("📊 Slide 1: Ana performans qrafiki\n")
cat("📊 Slide 2: Qrup müqayisə qrafiki\n")
cat("📊 Slide 3: Effektivlik analizi\n\n")
return(list(
slide1 = slide1,
slide2 = slide2,
slide3 = slide3
))
}
# 18. Generate automated report
generate_visual_report <- function(results_df, output_format = "html") {
cat("=== AVTOMATİK VİZUAL HESABAT ===\n\n")
# Report metadata
report_info <- list(
title = "CAT Sistem Analizi Hesabatı",
date = Sys.Date(),
n_subjects = nrow(results_df),
analysis_type = "Comprehensive Visual Analysis"
)
# Key findings
key_findings <- list(
validity = round(cor(results_df$true_theta, results_df$estimated_theta), 3),
rmse = round(sqrt(mean(results_df$estimation_error^2)), 3),
precision_rate = round(mean(results_df$precision_met) * 100, 1),
efficiency = round(30 / mean(results_df$items_administered), 2)
)
# Report sections
cat("📋 HESABAT KOMPONENTLƏRİ:\n")
cat("1. Executive Summary\n")
cat("2. Performance Overview\n")
cat("3. Detailed Analysis\n")
cat("4. Quality Control\n")
cat("5. Recommendations\n\n")
# Recommendations based on findings
recommendations <- c()
if (key_findings$validity < 0.8) {
recommendations <- c(recommendations, "• Validity yaxşılaşdırılması lazımdır")
}
if (key_findings$rmse > 0.4) {
recommendations <- c(recommendations, "• Qiymətləndirmə dəqiqliyinin artırılması")
}
if (key_findings$precision_rate < 70) {
recommendations <- c(recommendations, "• Precision rate artırılması")
}
if (key_findings$efficiency < 1.5) {
recommendations <- c(recommendations, "• Test səmərəliliyinin optimallaşdırılması")
}
if (length(recommendations) == 0) {
recommendations <- "✅ Sistem əla performans göstərir"
}
cat("💡 ƏSaS TOVSİYƏLƏR:\n")
cat(paste(recommendations, collapse = "\n"), "\n\n")
cat("📁 Hesabat faylları (", output_format, " formatında):\n")
cat("• cat_visual_report.", output_format, "\n")
cat("• interactive_dashboard.html\n")
cat("• presentation_slides.pptx\n")
cat("• technical_appendix.pdf\n\n")
return(list(
report_info = report_info,
key_findings = key_findings,
recommendations = recommendations
))
}
# Export və reporting
all_plots <- list(
accuracy = plot_accuracy(results_summary),
error_dist = plot_error_distribution(results_summary),
items_dist = plot_items_distribution(results_summary),
se_vs_items = plot_se_vs_items(results_summary)
)
export_info <- export_visualizations(all_plots)
## === VİZUALLAşDIRMA EKSPORTu ===
##
## Export directory: cat_visualizations
## Export formatları: png, pdf, svg
##
## 📁 Directory yaradılır...
## 📊 Export edilir: accuracy.png
## 📊 Export edilir: accuracy.pdf
## 📊 Export edilir: accuracy.svg
## 📊 Export edilir: error_dist.png
## 📊 Export edilir: error_dist.pdf
## 📊 Export edilir: error_dist.svg
## 📊 Export edilir: items_dist.png
## 📊 Export edilir: items_dist.pdf
## 📊 Export edilir: items_dist.svg
## 📊 Export edilir: se_vs_items.png
## 📊 Export edilir: se_vs_items.pdf
## 📊 Export edilir: se_vs_items.svg
##
## ✅ Bütün qrafiklər uğurla export edildi!
##
## 📋 Index faylı yaradılır: visualization_index.html
## 🔗 Sharing link yaradılır: cat_analysis_report.html
## === PRESENTASİYA QRAFİKLƏRİ ===
##
## 📊 Slide 1: Ana performans qrafiki
## 📊 Slide 2: Qrup müqayisə qrafiki
## 📊 Slide 3: Effektivlik analizi
## === AVTOMATİK VİZUAL HESABAT ===
##
## 📋 HESABAT KOMPONENTLƏRİ:
## 1. Executive Summary
## 2. Performance Overview
## 3. Detailed Analysis
## 4. Quality Control
## 5. Recommendations
##
## 💡 ƏSaS TOVSİYƏLƏR:
## • Precision rate artırılması
##
## 📁 Hesabat faylları ( html formatında):
## • cat_visual_report. html
## • interactive_dashboard.html
## • presentation_slides.pptx
## • technical_appendix.pdf
# Presentation slides göstərimi
grid.arrange(presentation_slides$slide1, presentation_slides$slide2, ncol = 2)
Bu bölmədə CAT simulyasiya nəticələrinin hərtərəfli vizual təhlili üçün professional visualizasiya sistemi yaratdıq.
Basic Plots: Fundamental performance indicators
Advanced Dashboards: Multi-dimensional analysis tools
Interactive Elements: Dynamic exploration capabilities
Specialized Charts: Domain-specific visualizations
Executive Dashboards: High-level summary views
Technical Analysis: Detailed diagnostic plots
Comparative Views: Scenario comparison tools
Quality Control: Process monitoring charts
Multiple Formats: PNG, PDF, SVG, HTML support
Automated Reports: Self-generating documentation
Presentation Ready: Professional slide templates
Interactive Sharing: Web-based dashboards
Visual Evidence: Data-driven decision making
Trend Detection: Pattern recognition və early warning
Performance Monitoring: Real-time quality control
Stakeholder Communication: Clear və compelling presentation
Exploratory Analysis: Data pattern discovery
Hypothesis Testing: Visual validation tools
Publication Ready: Journal-quality graphics
Reproducible Research: Automated visualization pipelines
Quality Assurance: Visual QC protocols
Process Improvement: Performance optimization guides
Training Materials: Educational visualization tools
Documentation: Comprehensive visual records
Clarity over Complexity: Simple və clear messaging
Consistency: Unified visual language
Accessibility: Color-blind friendly palettes
Professional Aesthetics: Publication-quality standards
Scalability: Efficient rendering for large datasets
Interactivity: User-friendly exploration tools
Responsiveness: Multi-device compatibility
Performance: Fast loading və smooth interaction
Audience Awareness: Tailored to viewer expertise
Story Telling: Narrative-driven presentation
Action Orientation: Clear recommendations
Evidence Based: Data-supported conclusions
AI-Powered Insights: Automated pattern detection
Real-time Analytics: Live data visualization
AR/VR Integration: Immersive data exploration
Voice Interaction: Natural language queries
Custom Themes: Brand-specific styling
Advanced Interactions: Drill-down capabilities
Integration APIs: Third-party tool connection
Cloud Deployment: Scalable hosting solutions
Personalization: User-specific dashboards
Mobile Optimization: Touch-friendly interfaces
Collaborative Features: Team-based analysis tools
Learning Paths: Progressive skill development
Qeyd: Bu vizual analiz sistemi CAT tədqiqatları və praktiki tətbiqlər üçün professional səviyyədə visualization toolkit təqdim edir. Sistem modular struktura malikdir və müxtəlif tələblərə uyğunlaşdırıla bilər.