featuretools.primitives.ExpandingTrend#

class featuretools.primitives.ExpandingTrend(gap=1, min_periods=1)[source]#

计算给定窗口内事件的扩展趋势.

Description:

给定一个日期时间列表,返回从当前行开始,距离当前行 gap 行之外的扩展趋势. 扩展原语计算在给定时间点的原语值,使用所有可用的数据,直到相应的时间点.

输入的日期时间应为单调递增.

Parameters:
  • gap (int, 可选) – 指定在可用数据开始之前,从每个实例向后跳过的间隔.对应于行数.默认为 1.

  • min_periods (int, 可选) – 执行窗口计算所需的最小观测数.默认为 1.

Examples

>>> import pandas as pd
>>> expanding_trend = ExpandingTrend()
>>> times = pd.date_range(start='2019-01-01', freq='1D', periods=5)
>>> ans = expanding_trend(times, [5, 4, 3, 2, 1]).tolist()
>>> [round(x, 2) for x in ans]
[nan, nan, nan, -1.0, -1.0]

我们也可以控制扩展计算前的间隔.

>>> import pandas as pd
>>> expanding_trend = ExpandingTrend(gap=0)
>>> times = pd.date_range(start='2019-01-01', freq='1D', periods=5)
>>> ans = expanding_trend(times, [5, 4, 3, 2, 1]).tolist()
>>> [round(x, 2) for x in ans]
[nan, nan, -1.0, -1.0, -1.0]

我们还可以控制滚动计算所需的最小周期数.

>>> import pandas as pd
>>> expanding_trend = ExpandingTrend(min_periods=3)
>>> times = pd.date_range(start='2019-01-01', freq='1min', periods=5)
>>> ans = expanding_trend(times, [50, 4, 13, 22, 10]).tolist()
>>> [round(x, 2) for x in ans]
[nan, nan, nan, -18.5, -7.5]
__init__(gap=1, min_periods=1)[source]#

Methods

__init__([gap, min_periods])

flatten_nested_input_types(input_types)

将嵌套的列模式输入展平成一个列表.

generate_name(base_feature_names)

generate_names(base_feature_names)

get_args_string()

get_arguments()

get_description(input_column_descriptions[, ...])

get_filepath(filename)

get_function()

Attributes

base_of

base_of_exclude

commutative

default_value

Default value this feature returns if no data found.

description_template

input_types

woodwork.ColumnSchema types of inputs

max_stack_depth

name

Name of the primitive

number_output_features

Number of columns in feature matrix associated with this feature

return_type

ColumnSchema type of return

stack_on

stack_on_exclude

stack_on_self

uses_calc_time

uses_full_dataframe