Learn R Programming

featuretoolsR (version 0.4.4)

calculate_feature_matrix: Calculate feature matrix

Description

This function is used to create a feature matrix based on a custom list of features (usually created from save_features).

Usage

calculate_feature_matrix(entityset, features, ...)

Arguments

entityset

The entityset on which to create features.

features

The features to create based on previous runs of dfs.

...

Additional parameters passed to `featuretoools.calculate_feature_matrix`.

Value

A feature matrix

Examples

Run this code
# NOT RUN {
library(magrittr)

# Create some mock data
set_1 <- data.frame(key = 1:100, value = sample(letters, 100, TRUE), stringsAsFactors = TRUE)
set_2 <- data.frame(key = 1:100, value = sample(LETTERS, 100, TRUE), stringsAsFactors = TRUE)
# Common variable: `key`

# Create features and save them
as_entityset(set_1, index = "key", entity_id = "set_1", id = "demo") %>%
  add_entity(entity_id = "set_2", df = set_2, index = "key") %>%
  add_relationship(
    parent_set = "set_1",
    child_set = "set_2",
    parent_idx = "key",
    child_idx = "key"
  ) %>%
  dfs(target_entity = "set_1", trans_primitives = c("and")) %>%
  extract_features() %>%
  save_features(filename = "some.features")

# Re-create entityset, but rather than dfs use calcualte_feature_matrix.
es <- as_entityset(set_1, index = "key", entity_id = "set_1", id = "demo") %>%
  add_entity(entity_id = "set_2", df = set_2, index = "key") %>%
  add_relationship(
    parent_set = "set_1",
    child_set = "set_2",
    parent_idx = "key",
    child_idx = "key"
  )
calculate_feature_matrix(entityset = es, features = load_features("some.features"))
# }

Run the code above in your browser using DataLab