detect_xor {detectXOR} | R Documentation |
Detect XOR Patterns in Variable Pairs
Description
Identifies XOR-shaped relationships between variables using statistical tests and pattern detection.
Usage
detect_xor(
data,
class_col = "class",
check_tau = TRUE,
compute_axes_parallel_significance = TRUE,
p_threshold = 0.05,
tau_threshold = 0.3,
abs_diff_threshold = 20,
split_method = "quantile",
max_cores = 1,
extreme_handling = "winsorize",
winsor_limits = c(0.05, 0.95),
scale_data = TRUE,
use_complete = TRUE
)
Arguments
data |
Data frame containing features and class column |
class_col |
Name of class column (default: "class") |
check_tau |
Logical - compute classwise tau coefficients (default: TRUE) |
compute_axes_parallel_significance |
Logical - compute Wilcoxon tests (default: TRUE) |
p_threshold |
Significance threshold (default: 0.05) |
tau_threshold |
Tau coefficient threshold (default: 0.3) |
abs_diff_threshold |
Absolute difference threshold for patterns (default: 20) |
split_method |
Method for splitting data ("quantile" or "range") (default: "quantile") |
max_cores |
Maximum cores for parallel processing (default: NULL = automatic) |
extreme_handling |
Method for handling extreme values; options include "winsorize" or "none" (default: "winsorize") |
winsor_limits |
Numeric vector of length 2 specifying lower and upper quantiles for winsorization (default: c(0.05, 0.95)) |
scale_data |
Logical; whether to scale/standardize the data before analysis (default: TRUE) |
use_complete |
Logical; whether to use only complete cases (default: TRUE) |
Details
This function performs an analysis to detect XOR-like patterns in pairwise variable relationships within two-class data sets. The analysis pipeline includes:
Data preprocessing (winsorization, scaling, complete cases)
Tile pattern analysis using chi-squared tests
Classwise Kendall tau correlation analysis
Group-wise Wilcoxon significance tests
The function automatically handles parallel processing when multiple cores are available and returns both a summary data frame and detailed results for further analysis.
Value
List containing:
results_df |
Data frame with detection results for all variable pairs |
pair_list |
Detailed analysis results for each variable pair |
See Also
generate_spaghetti_plot_from_results
for spaghetti plot visualization, generate_xy_plot_from_results
for scatter plot visualization, generate_xor_reportConsole
for console reporting, generate_xor_reportHTML
for HTML report generation, XOR_data
for example dataset
Examples
# Load example data
data(XOR_data)
# Run XOR detection
results <- detect_xor(data = XOR_data, class_col = "class")
# View summary of detected patterns
print(results$results_df["xor_shape_detected"])
# Generate visualizations
spaghetti_plot <- generate_spaghetti_plot_from_results(
results = results,
data = XOR_data,
class_col = "class"
)
print(spaghetti_plot)
xy_plot <- generate_xy_plot_from_results(
results = results,
data = XOR_data,
class_col = "class"
)
print(xy_plot)
# Generate console report (doesn't write files)
generate_xor_reportConsole(results, XOR_data, "class", show_plots = FALSE)
# View detailed results for detected pairs
detected_pairs <- results$results_df[results$results_df$xor_shape_detected == TRUE, ]
print(detected_pairs)