本文整理汇总了Python中featuretools.synthesis.DeepFeatureSynthesis类的典型用法代码示例。如果您正苦于以下问题:Python DeepFeatureSynthesis类的具体用法?Python DeepFeatureSynthesis怎么用?Python DeepFeatureSynthesis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeepFeatureSynthesis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pickle_features
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)
示例2: test_pickle_features_with_custom_primitive
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)
示例3: test_where_primitives
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
示例4: test_allowed_paths
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
示例5: test_makes_agg_features
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)'))
示例6: test_makes_dfeatures_of_agg_primitives
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)'))
示例7: test_handles_cumsum_entity_groupby
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)'))
示例8: test_handles_time_since_previous_entity_groupby
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'))
示例9: test_makes_trans_feat
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)'))
示例10: test_handles_diff_entity_groupby
def test_handles_diff_entity_groupby(es):
dfs_obj = DeepFeatureSynthesis(target_entity_id='log',
entityset=es,
agg_primitives=[],
trans_primitives=[Diff])
features = dfs_obj.build_features()
assert (feature_with_name(features, 'DIFF(value by session_id)'))
assert (feature_with_name(features, 'DIFF(value by product_id)'))
示例11: test_makes_dfeatures
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'))
示例12: test_makes_agg_features_of_trans_primitives
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))'))
示例13: test_case_insensitive
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))'))
示例14: test_makes_agg_features_from_mixed_str
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)'))
示例15: test_makes_agg_features_with_where
def test_makes_agg_features_with_where(es):
es.add_interesting_values()
dfs_obj = DeepFeatureSynthesis(target_entity_id='sessions',
entityset=es,
agg_primitives=[Count],
trans_primitives=[])
features = dfs_obj.build_features()
assert (feature_with_name(features,
'COUNT(log WHERE priority_level = 0)'))