calculate_feature_matrix: Calculate feature matrix

Description Usage Arguments Value Examples

View source: R/calculate_feature_matrix.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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"))

featuretoolsR documentation built on April 25, 2020, 5:05 p.m.