Question: Write the following functions in R. Each function, takes arguments named acutals and predictions. Both actuals and predictions should each be vectors of 1s and
Write the following functions in R. Each function, takes arguments named acutals and predictions.
- Both actuals and predictions should each be vectors of 1s and 0s.
- Actuals represents the actual values for a dataset. Predictions represents the predicted values that are output from a model. # The following function calculates the numbers of True Positives TP <- function(actuals, prediction) # The following function calculates the numbers of False Positives FP <- function(actuals, prediction) # The following function calculates the numbers of True Negatives TN <- function(actuals, prediction) # The following function calculates the numbers of False Negatives FN <- function(actuals, prediction) # The following function calculates the precision of the predictions precision <- function (actuals, predictions) # The following function calculates the recall of the predictions recall <- function (actuals, predictions) # fallOut <- function(acutals, predictions) # The following calculates the f-beta-measure of the precision and the recall. # When beta is 1 (i.e. the default), the function calculates the f1measure. fMeasure <- function(acutals, predictions, )
- # Average Precision # use this formula: # where k is the rank in the sequence of retrieved documents, n is the number of retrieved documents, # P(k) is the precision at cut-off k in the list, # and rel(k) is an indicator function equaling 1 if the item at rank k is a relevant document, zero otherwise. avgPrecision <- function(actual, predictions)
precisionAtK <- function (actuals, prediction, (prediction))
RPrecision <- function (actuals, prediction, (prediction))
# Each item in the listOfQueryResults contains a vector of actuals and a vector of predictions. meanAvgPrecision <- function(listOfQueryResults)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
