Learn R Programming

flacco (version 1.0)

FeatureObject: Create a Feature Object

Description

Create a FeatureObject, which will be used as input for all the feature computations.

Usage

createFeatureObject(init, X, y, fun, minimize, lower, upper, blocks, objective)

Arguments

init
[data.frame] A data.frame, which can be used as initial design. If not provided, it will be created either based on X and y or X and fun.
X
[data.frame or matrix] A data.frame or matrix containing the features of the initial design. If not provided, it will be extracte
y
[numeric or integer] A vector containing the objective values of the initial design. If not provided, it will be extracted from init.
fun
[function] A function, which allows the computation of the objective values. If it is not provided, features that require additional function evaluations, can't be computed.
minimize
[logical(1)] Should the objective function be minimized? The default is TRUE.
lower
[numeric or integer] The lower limits per dimension.
upper
[numeric or integer] The upper limits per dimension.
blocks
[integer] The number of blocks per dimension.
objective
[character(1)] The name of the feature, which contains the objective values. The default is "y".

Value

Examples

Run this code
# (1a) create a feature object using X and y:
X = t(replicate(n = 500, expr = runif(n = 3, min = -10, max = 10)))
y = apply(X, 1, function(x) sum(x^2))
feat.object1 = createFeatureObject(X = X, y = y,
  lower = -10, upper = 10, blocks = c(5, 10, 4))

# (1b) create a feature object using X and fun:
feat.object2 = createFeatureObject(X = X,
  fun = function(x) sum(sin(x) * x^2),
  lower = -10, upper = 10, blocks = c(5, 10, 4))

# (1c) create a feature object using a data.frame:
feat.object3 = createFeatureObject(iris[,-5], blocks = 5,
  objective = "Petal.Length")

# (2) have a look at the feature objects:
feat.object1
feat.object2
feat.object3

# (3) now, one could calculate features
calculateFeatureSet(feat.object1, "cm_conv", control = list(cm_conv.diag = TRUE))
calculateFeatureSet(feat.object2, "cm_grad")
library(plyr)
calculateFeatureSet(feat.object3, "cm_angle", control = list(cm_angle.show_warnings = FALSE))

Run the code above in your browser using DataLab