conformal_pvalues {conformalpvalue}R Documentation

Conformal P-values Calculation

Description

This function calculates conformal p-values based of binary class labels for test data.

Usage

conformal_pvalues(train_data, calib_data, test_data, target_col, method)

Arguments

train_data

A data frame containing the training data with the target variable.

calib_data

A data frame containing the calibration data with the target variable.

test_data

A data frame containing the test data.

target_col

The name of the target variable column.

method

A character string specifying the classification method to use. Options are 'naiveBayes', 'svm', and 'glm'.

This function trains a Naive Bayes classifier, computes non-conformity scores on the calibration data and test data, and calculates conformal p-values of both classes "0" and "1" using the conformal prediction for a binary classification problem.

Value

A matrix containing p-values for each test case and class.

Examples


# Create dummy train_data, calib_data, and test_data
train_data <- data.frame(
  x1 = as.numeric(rnorm(50, 1, 2)),
  x2 = as.numeric(rnorm(50, 2.5, 3)),
  target = as.factor(rbinom(50, 1, 0.5))
)
calib_data <- data.frame(
  x1 = as.numeric(rnorm(50, 1, 2)),
  x2 = as.numeric(rnorm(50, 2.5, 3)),
  target = as.factor(rbinom(50, 1, 0.5))
)
test_data <- data.frame(
  x1 = as.numeric(rnorm(50, 1, 2)),
  x2 = as.numeric(rnorm(50, 2.5, 3))
)
p_values <- conformal_pvalues(train_data, calib_data, test_data, target="target", method="svm")


[Package conformalpvalue version 0.1.0 Index]