calcAccuracy: Calculate the accuracy of a model

Description Usage Arguments Value Examples

View source: R/hello.R

Description

The accuracy is the fraction of predictions that were true. It is calculated by dividing the number of correct predictions through the total number of predictions.

Usage

1
calcAccuracy(testresult)

Arguments

testresult

A matrix containing actual and predicted values as returned by the function test_model().

Value

A percentage value between 0 and 1. 0.5 means that 50

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Example for the case that all datasets are located in S:/

# Prepare data
jams <- load_jams("S:/", loadExample = TRUE)
jams_with_genre <- add_genres_to_jams(jams, "S:/", loadExample = TRUE)
jam_sequence <- create_time_sequence(jams_with_genre)
splitted_data <- split_data(jam_sequence)
training_dataset <- splitted_data[[1]]
test_dataset <- splitted_data[[2]]

# Train model
hmm <- MIR_hmm(training_dataset)
test_results <- test_model(hmm,test_dataset)
# Calculate accuracy
print(calcAccuracy(test_results))

githerbert/HMM documentation built on May 30, 2019, 12:46 p.m.