Learn R Programming

DriveML (version 0.1.5)

generateFeature: Automated column transformer

Description

This function automatically scans through each variable and generate features based on the type listed in the "details"

Usage

generateFeature(data, varlist, type = "Frequent", method = NULL)

Value

generated transformed features

Arguments

data

[data.frame | Required] dataframe or data.table

varlist

[text | Required] variable list to generate the additional features

type

[text | Required] variable transformation with type - 'Dummy','Outlier','Frequent' or 'Interaction'

method

[text | Required] input for variabe transformation for type = 'Frequent' then the method should be 'Frequency' or 'Percent'. Please refer to the "details" section to know more

Details

This function is for generating features based on different transformation methods such as interaction, outliers, Dummy coding, etc.

Interaction type

  • multiply - multiplication

  • add - addition

  • substract - substraction

  • divide - division

Frequency type

  • Frequency - frequency

  • Percent - percentage

Outlier type

  • Flag - flag outlier values like 1 or 0

  • Capping - impute outlier value by 95th or 5th percentile value

Date type

  • Year

  • Month

  • Quarter

  • Week

Examples

Run this code
# Generate interaction features
generateFeature(heart, varlist = c("cp", "chol", "trestbps"), type = "Interaction",
method = "add")
generateFeature(heart, varlist = c("cp", "chol", "trestbps"), type = "Interaction",
method = "multiply")

# Generate frequency features
generateFeature(heart, varlist = c("cp", "thal"), type = "Frequent", method = "Percent")
generateFeature(heart, varlist = c("cp", "thal"), type = "Frequent", method = "Frequency")

Run the code above in your browser using DataLab