createGENEAmodel: Create training data decision tree model

View source: R/createGENEAmodel.R

createGENEAmodelR Documentation

Create training data decision tree model

Description

From data frame create a decision tree that can be used for classifying data into specified categories. The data frame may optionally contain a reserved column Source, specifying the provenance of the record. The data frame must contain a column, by default named Activity, specifing the classes into which the model fit should be classified.

Usage

createGENEAmodel(
  data,
  outputtree = NULL,
  features = c("Segment.Duration", "Principal.Frequency.mad", "UpDown.sd", "Degrees.sd"),
  category = "Activity",
  plot = TRUE,
  verbose = TRUE,
  ...
)

Arguments

data

data frame containing segmented GENEActiv bin data.

outputtree

name of the png file that shows the classification tree plot.

features

character vector naming independent variables to use in classification. Alternatively, a numeric vector specifying the variables to pass to the classification or NULL, in which case all variables are used in the order of the supplied training dataset. Note that including large numbers of variables (>7) may result in long run times.

category

single character naming the dependent variable to use (default 'Activity').

plot

a logical value indicating whether a plot of the classification tree should be plotted. The default is TRUE.

verbose

single logical should additional progress reporting be printed at the console? (default TRUE)

...

other arguments for rpart

Details

The function will create an rpart classification tree for the training data based upon the parameters passed to features. The model created, an GENEA rpart object can be used within the function "classifyGENEA" to classify GENEA bin files.

Value

A GENEA rpart fit.

See Also

The returned object can be interrogated with features, the variables used in defining the model, and "levels", the response categories predicted by the model.

Examples

## dataPath <- file.path(system.file(package = "GENEAclassify"),
##                                   "testdata",
##                                   "trainingData9.csv")
##
## t1 <- read.csv(file = dataPath)
## 
## f1 <- createGENEAmodel(data = t1,
##                        features = c("Degrees.var",
##                                     "UpDown.mad",
##                                     "Magnitude.mean"),
##                        category = "Activity")
## 
## class(f1)
## levels(f1)
## features(f1)
## plot(f1)
## text(f1)

GENEAclassify documentation built on March 31, 2023, 9:01 p.m.