def test_cum_handles_uses_full_entity(es): def check(feature): pandas_backend = PandasBackend(es, [feature]) df_1 = pandas_backend.calculate_all_features(instance_ids=[0, 1, 2], time_last=None) df_2 = pandas_backend.calculate_all_features(instance_ids=[2], time_last=None) # check that the value for instance id 2 matches assert (df_2.loc[2] == df_1.loc[2]).all() for primitive in [CumSum, CumMean, CumMax, CumMin]: check(primitive(es['log']['value'], es['log']['session_id'])) check(CumCount(es['log']['id'], es['log']['session_id']))
verbose = 1, target_entity='WIP', agg_primitives=[], trans_primitives=['cum_sum', 'cum_count'], groupby_trans_primitives=['cum_sum', 'cum_count'], #累積總計、累積總數 ignore_variables={'WIP': ['PRIORITY']} ) feature_matrix # %% from featuretools.primitives import CumCount #累績總數 cum_count = CumCount() cum_count([1, 2, 3, 4, None, 5]).tolist() # %% from featuretools.primitives import CumCount from featuretools.primitives import IsWeekend #累績總數 cum_count = CumCount() cum_count([1, 2, 3, 4, None, 5]).tolist() isWkend = IsWeekend() feature_matrix, features_list = ft.dfs(entityset=es, verbose = 1, target_entity='WIP', agg_primitives=[], trans_primitives=['cum_sum','cum_count','is_weekend'],