当前位置: 首页>>代码示例>>Python>>正文


Python DeepFeatureSynthesis.build_features方法代码示例

本文整理汇总了Python中featuretools.synthesis.DeepFeatureSynthesis.build_features方法的典型用法代码示例。如果您正苦于以下问题:Python DeepFeatureSynthesis.build_features方法的具体用法?Python DeepFeatureSynthesis.build_features怎么用?Python DeepFeatureSynthesis.build_features使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在featuretools.synthesis.DeepFeatureSynthesis的用法示例。


在下文中一共展示了DeepFeatureSynthesis.build_features方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_max_hlevel

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_max_hlevel(es):
    kwargs = dict(
        target_entity_id='log',
        entityset=es,
        agg_primitives=[Count, Last],
        trans_primitives=[Hour],
        max_depth=-1,
    )

    dfs_h_n1 = DeepFeatureSynthesis(max_hlevel=-1, **kwargs)
    dfs_h_0 = DeepFeatureSynthesis(max_hlevel=0, **kwargs)
    dfs_h_1 = DeepFeatureSynthesis(max_hlevel=1, **kwargs)
    feats_n1 = dfs_h_n1.build_features()
    feats_n1 = [f.get_name() for f in feats_n1]
    feats_0 = dfs_h_0.build_features()
    feats_0 = [f.get_name() for f in feats_0]
    feats_1 = dfs_h_1.build_features()
    feats_1 = [f.get_name() for f in feats_1]

    customer_log = Last(es['log']['value'], es['customers'])
    session_log = Last(es['log']['value'], es['sessions'])
    log_customer_log = Feature(customer_log, es['log'])
    log_session_log = Feature(session_log, es['log'])
    assert log_customer_log.get_name() in feats_n1
    assert log_session_log.get_name() in feats_n1

    assert log_customer_log.get_name() not in feats_1
    assert log_session_log.get_name() in feats_1

    assert log_customer_log.get_name() not in feats_0
    assert log_session_log.get_name() not in feats_0
开发者ID:rgolovnya,项目名称:featuretools,代码行数:33,代码来源:test_deep_feature_synthesis.py

示例2: test_where_primitives

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_where_primitives(es):
    es = copy.deepcopy(es)
    es['sessions']['device_type'].interesting_values = [0]
    kwargs = dict(
        target_entity_id='customers',
        entityset=es,
        agg_primitives=[Count, Last],
        trans_primitives=[Absolute],
        max_depth=3,
    )
    dfs_unconstrained = DeepFeatureSynthesis(**kwargs)
    dfs_constrained = DeepFeatureSynthesis(where_primitives=['last'], **kwargs)
    features_unconstrained = dfs_unconstrained.build_features()
    features = dfs_constrained.build_features()

    where_feats_unconstrained = [f for f in features_unconstrained
                                 if f.where is not None]
    where_feats = [f for f in features
                   if f.where is not None]

    assert len(where_feats_unconstrained) >= 1

    assert len([f for f in where_feats_unconstrained
                if isinstance(f, Last)]) == 0
    assert len([f for f in where_feats_unconstrained
                if isinstance(f, Count)]) > 0

    assert len([f for f in where_feats
                if isinstance(f, Last)]) > 0
    assert len([f for f in where_feats
                if isinstance(f, Count)]) == 0
    assert len([d for f in where_feats
                for d in f.get_deep_dependencies()
                if isinstance(d, Absolute)]) > 0
开发者ID:rgolovnya,项目名称:featuretools,代码行数:36,代码来源:test_deep_feature_synthesis.py

示例3: test_allowed_paths

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_allowed_paths(es):
    kwargs = dict(
        target_entity_id='customers',
        entityset=es,
        agg_primitives=[Last],
        trans_primitives=[],
        max_depth=2,
        seed_features=[]
    )
    dfs_unconstrained = DeepFeatureSynthesis(**kwargs)
    features_unconstrained = dfs_unconstrained.build_features()

    unconstrained_names = [f.get_name() for f in features_unconstrained]
    customers_session_feat = Last(es['sessions']['device_type'],
                                  es['customers'])
    customers_session_log_feat = Last(es['log']['value'], es['customers'])
    assert customers_session_feat.get_name() in unconstrained_names
    assert customers_session_log_feat.get_name() in unconstrained_names

    dfs_constrained = DeepFeatureSynthesis(allowed_paths=[['customers',
                                                           'sessions']],
                                           **kwargs)
    features = dfs_constrained.build_features()
    names = [f.get_name() for f in features]
    assert customers_session_feat.get_name() in names
    assert customers_session_log_feat.get_name() not in names
开发者ID:rgolovnya,项目名称:featuretools,代码行数:28,代码来源:test_deep_feature_synthesis.py

示例4: test_stacking_where_primitives

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_stacking_where_primitives(es):
    es = copy.deepcopy(es)
    es['sessions']['device_type'].interesting_values = [0]
    es['log']['product_id'].interesting_values = ["coke_zero"]
    kwargs = dict(
        target_entity_id='customers',
        entityset=es,
        agg_primitives=[Count, Last],
        max_depth=3,
    )
    dfs_where_stack_limit_1 = DeepFeatureSynthesis(where_primitives=['last', Count],
                                                   **kwargs)
    dfs_where_stack_limit_2 = DeepFeatureSynthesis(where_primitives=['last', Count],
                                                   where_stacking_limit=2,
                                                   **kwargs)
    stack_limit_1_features = dfs_where_stack_limit_1.build_features()
    stack_limit_2_features = dfs_where_stack_limit_2.build_features()

    where_stack_1_feats = [f for f in stack_limit_1_features
                           if f.where is not None]
    where_stack_2_feats = [f for f in stack_limit_2_features
                           if f.where is not None]

    assert len(where_stack_1_feats) >= 1
    assert len(where_stack_2_feats) >= 1

    assert len([f for f in where_stack_1_feats
                if isinstance(f, Last)]) > 0
    assert len([f for f in where_stack_1_feats
                if isinstance(f, Count)]) > 0

    assert len([f for f in where_stack_2_feats
                if isinstance(f, Last)]) > 0
    assert len([f for f in where_stack_2_feats
                if isinstance(f, Count)]) > 0

    stacked_where_limit_1_feats = []
    stacked_where_limit_2_feats = []
    where_double_where_tuples = [
        (where_stack_1_feats, stacked_where_limit_1_feats),
        (where_stack_2_feats, stacked_where_limit_2_feats)
    ]
    for where_list, double_where_list in where_double_where_tuples:
        for feature in where_list:
            for base_feat in feature.base_features:
                if base_feat.where is not None:
                    double_where_list.append(feature)

    assert len(stacked_where_limit_1_feats) == 0
    assert len(stacked_where_limit_2_feats) > 0
开发者ID:rgolovnya,项目名称:featuretools,代码行数:52,代码来源:test_deep_feature_synthesis.py

示例5: test_pickle_features_with_custom_primitive

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_pickle_features_with_custom_primitive(es):
    NewMean = make_agg_primitive(
        np.nanmean,
        name="NewMean",
        input_types=[Numeric],
        return_type=Numeric,
        description="Calculate means ignoring nan values")
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   agg_primitives=[Last, Mean, NewMean],
                                   trans_primitives=[],
                                   max_features=20)

    features_no_pickle = dfs_obj.build_features()
    assert any([isinstance(feat, NewMean) for feat in features_no_pickle])
    dir_path = os.path.dirname(os.path.realpath(__file__))
    filepath = os.path.join(dir_path, 'test_feature')
    es_filepath = os.path.join(dir_path, 'test_entityset')

    # pickle entityset
    save_obj_pickle(es, es_filepath)

    ft.save_features(features_no_pickle, filepath)
    features_pickle = ft.load_features(filepath)
    for feat_1, feat_2 in zip(features_no_pickle, features_pickle):
        assert feat_1.hash() == feat_2.hash()
        assert feat_1.entityset == feat_2.entityset

    # file is smaller than entityset in memory
    assert os.path.getsize(filepath) < asizeof(es)

    # file is smaller than entityset pickled
    assert os.path.getsize(filepath) < os.path.getsize(es_filepath)
    os.remove(filepath)
    os.remove(es_filepath)
开发者ID:rgolovnya,项目名称:featuretools,代码行数:37,代码来源:test_deep_feature_synthesis.py

示例6: test_pickle_features

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_pickle_features(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   agg_primitives=[Last, Mean],
                                   trans_primitives=[],
                                   max_features=20)

    features_no_pickle = dfs_obj.build_features()

    dir_path = os.path.dirname(os.path.realpath(__file__))
    filepath = os.path.join(dir_path, 'test_feature')
    es_filepath = os.path.join(dir_path, 'test_entityset')

    # pickle entityset
    save_obj_pickle(es, es_filepath)

    ft.save_features(features_no_pickle, filepath)
    features_pickle = ft.load_features(filepath)
    for feat_1, feat_2 in zip(features_no_pickle, features_pickle):
        assert feat_1.hash() == feat_2.hash()
        assert feat_1.entityset == feat_2.entityset

    # file is smaller than entityset in memory
    assert os.path.getsize(filepath) < asizeof(es)

    # file is smaller than entityset pickled
    assert os.path.getsize(filepath) < os.path.getsize(es_filepath)
    os.remove(filepath)
    os.remove(es_filepath)
开发者ID:rgolovnya,项目名称:featuretools,代码行数:31,代码来源:test_deep_feature_synthesis.py

示例7: test_makes_trans_feat

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_makes_trans_feat(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='log',
                                   entityset=es,
                                   agg_primitives=[],
                                   trans_primitives=[Hour])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, 'HOUR(datetime)'))
开发者ID:rgolovnya,项目名称:featuretools,代码行数:10,代码来源:test_deep_feature_synthesis.py

示例8: test_handles_time_since_previous_entity_groupby

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_handles_time_since_previous_entity_groupby(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='log',
                                   entityset=es,
                                   agg_primitives=[],
                                   trans_primitives=[TimeSincePrevious])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, 'time_since_previous_by_session_id'))
开发者ID:rgolovnya,项目名称:featuretools,代码行数:10,代码来源:test_deep_feature_synthesis.py

示例9: test_handles_cumsum_entity_groupby

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_handles_cumsum_entity_groupby(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   agg_primitives=[],
                                   trans_primitives=[CumMean])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, u'customers.CUM_MEAN(age by région_id)'))
开发者ID:rgolovnya,项目名称:featuretools,代码行数:10,代码来源:test_deep_feature_synthesis.py

示例10: test_makes_agg_features

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_makes_agg_features(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   agg_primitives=[Last],
                                   trans_primitives=[])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, 'LAST(log.value)'))
开发者ID:rgolovnya,项目名称:featuretools,代码行数:10,代码来源:test_deep_feature_synthesis.py

示例11: test_makes_dfeatures_of_agg_primitives

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_makes_dfeatures_of_agg_primitives(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   agg_primitives=[Last],
                                   trans_primitives=[])
    features = dfs_obj.build_features()
    assert (feature_with_name(features,
                              'customers.LAST(sessions.device_type)'))
开发者ID:rgolovnya,项目名称:featuretools,代码行数:10,代码来源:test_deep_feature_synthesis.py

示例12: test_makes_agg_features_of_trans_primitives

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_makes_agg_features_of_trans_primitives(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   filters=[],
                                   agg_primitives=[Last],
                                   trans_primitives=[Hour])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, 'LAST(log.HOUR(datetime))'))
开发者ID:wuqixiaobai,项目名称:featuretools,代码行数:11,代码来源:test_deep_feature_synthesis.py

示例13: test_makes_dfeatures

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_makes_dfeatures(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   filters=[],
                                   agg_primitives=[],
                                   trans_primitives=[])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, 'customers.age'))
开发者ID:wuqixiaobai,项目名称:featuretools,代码行数:11,代码来源:test_deep_feature_synthesis.py

示例14: test_case_insensitive

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_case_insensitive(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   agg_primitives=['MiN'],
                                   trans_primitives=['AbsOlute'])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, 'MIN(log.value)'))
    assert (feature_with_name(features, 'ABSOLUTE(MIN(log.value_many_nans))'))
开发者ID:rgolovnya,项目名称:featuretools,代码行数:11,代码来源:test_deep_feature_synthesis.py

示例15: test_makes_agg_features_from_mixed_str

# 需要导入模块: from featuretools.synthesis import DeepFeatureSynthesis [as 别名]
# 或者: from featuretools.synthesis.DeepFeatureSynthesis import build_features [as 别名]
def test_makes_agg_features_from_mixed_str(es):
    dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
                                   entityset=es,
                                   agg_primitives=[Count, 'last'],
                                   trans_primitives=[])

    features = dfs_obj.build_features()
    assert (feature_with_name(features, 'LAST(log.value)'))
    assert (feature_with_name(features, 'COUNT(log)'))
开发者ID:rgolovnya,项目名称:featuretools,代码行数:11,代码来源:test_deep_feature_synthesis.py


注:本文中的featuretools.synthesis.DeepFeatureSynthesis.build_features方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。