Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete Mathematics and Its Applications

Authors: Kenneth H. Rosen

7th edition

0073383090, 978-0073383095

More Books

Students also viewed these Mathematics questions