【问题标题】:Using featuretool, how to use dfs primitives individually?使用 featuretool,如何单独使用 dfs 原语?
【发布时间】:2020-05-23 14:28:04
【问题描述】:

你能帮帮我吗?当我使用 feturestools 时,我使用 iris 数据集,它具有以下 4 个特征:f1、f2、f3、f4,当我使用 ft.dfs 时,我有 3 个问题。 1.发现feature_matrix的特征太多了。 “divide_by_feature”和“modulo_numeric”没有单独作用于原始特征。它首先作用divide_by_feature'然后得到4个新特征,然后对原始特征和新特征进行'modulo_numeric'。 我希望这两个原语可以单独作用于原始特征。我应该怎么做? 2. 我使用像 trans_primitives = ['subtract_numeric_scalar', 'modulo_numeric'] 这样的变换原语。我发现subtract_numeric_scalar可以传值,但是不知道怎么传? 3. 我想知道如何使用所有的变换原语?默认,trans_primitives=None,到目前为止,我可以这样解决它:trans_primitives = ['is_null','diff',...],但是,我认为这很麻烦。

你能给我一些建议吗?谢谢!

enter image description here

【问题讨论】:

    标签: featuretools


    【解决方案1】:
    1. 您可以使用max_depth 来控制功能的复杂性。当max_depth=1 时,图元将只使用原始特征。

      features = ft.dfs(
          entityset=es,
          target_entity='data',
          trans_primitives=['divide_by_feature', 'modulo_numeric'],
          features_only=True,
          max_depth=1,
      )
      
      [<Feature: f1>,
      <Feature: f2>,
      <Feature: f3>,
      <Feature: f4>,
      <Feature: 1 / f3>,
      <Feature: 1 / f1>,
      <Feature: 1 / f2>,
      <Feature: 1 / f4>,
      <Feature: f1 % f2>,
      <Feature: f4 % f3>,
      <Feature: f4 % f2>,
      <Feature: f1 % f3>,
      <Feature: f2 % f4>,
      <Feature: f4 % f1>,
      <Feature: f3 % f2>,
      <Feature: f3 % f1>,
      <Feature: f2 % f1>,
      <Feature: f3 % f4>,
      <Feature: f2 % f3>,
      <Feature: f1 % f4>]
      
    2. 您可以使用参数创建基元的实例。这就是您可以将值传递给subtract_numeric_scalar 的方式。

      from featuretools.primitives import SubtractNumericScalar
      
      ft.dfs(
          ...
          trans_primitives=[SubtractNumericScalar(value=2)]
      )
      
    3. 您可以通过从原语列表中提取名称来使用所有转换原语。

      primitives = ft.list_primitives()
      primitives = primitives.groupby('type')
      transforms = primitives.get_group('transform')
      transforms = transforms.name.values.tolist()
      
      ['less_than_scalar',
      'divide_numeric',
      'latitude',
      'add_numeric',
      'week',
      'greater_than_equal_to_scalar',
      'and',
      'multiply_numeric_scalar',
      'not',
      'second',
      'greater_than_scalar',
      'modulo_numeric_scalar',
      'scalar_subtract_numeric_feature',
      'diff',
      'day',
      'cum_min',
      'divide_by_feature',
      'less_than_equal_to',
      'time_since',
      'time_since_previous',
      'cum_count',
      'year',
      'is_null',
      'num_characters',
      'equal_scalar',
      'is_weekend',
      'less_than_equal_to_scalar',
      'longitude',
      'add_numeric_scalar',
      'month',
      'less_than',
      'or',
      'multiply_boolean',
      'percentile',
      'minute',
      'not_equal_scalar',
      'greater_than_equal_to',
      'modulo_by_feature',
      'multiply_numeric',
      'negate',
      'hour',
      'cum_max',
      'greater_than',
      'modulo_numeric',
      'subtract_numeric_scalar',
      'isin',
      'cum_mean',
      'divide_numeric_scalar',
      'num_words',
      'absolute',
      'cum_sum',
      'not_equal',
      'weekday',
      'equal',
      'haversine',
      'subtract_numeric']
      

      如果这有帮助,请告诉我。

    【讨论】:

      猜你喜欢
      • 2018-11-04
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多