How to use the featuretools.primitives.AggregationPrimitive function in featuretools

To help you get started, we’ve selected a few featuretools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / abs_energy.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import abs_energy


class AbsEnergy(AggregationPrimitive):
    """Returns the absolute energy of the time series
    which is the sum over the squared values.

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.abs_energy
    """
    name = "abs_energy"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def get_function(self):
        return abs_energy
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / energy_ratio_by_chunks.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import \
    energy_ratio_by_chunks


class EnergyRatioByChunks(AggregationPrimitive):
    """Calculates the sum of squares of chunk i out of N chunks expressed as a
    ratio with the sum of squares over the whole series.

    Args:
        num_segments (int) : Number of segments to divide the series into.
        segment_focus (int) : Segment number (starting at zero) to return a feature on.

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.energy_ratio_by_chunks
    """
    name = "energy_ratio_by_chunks"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def __init__(self, num_segments, segment_focus):
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / longest_strike_above_mean.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import \
    longest_strike_above_mean


class LongestStrikeAboveMean(AggregationPrimitive):
    """Returns the length of the longest consecutive subsequence in x that is
    bigger than the mean of x.

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.longest_strike_above_mean
    """
    name = "longest_strike_above_mean"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def get_function(self):
        return longest_strike_above_mean
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / index_mass_quantile.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import index_mass_quantile


class IndexMassQuantile(AggregationPrimitive):
    """Those apply features calculate the relative index i where q% of the mass
    of the time series x lie left of i. For example for q = 50% this feature
    calculator will return the mass center of the time series.

    Args:
        q (float) : Percentage of the mass of the time series.

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.index_mass_quantile
    """
    name = "index_mass_quantile"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def __init__(self, q):
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / linear_trend.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import linear_trend


class LinearTrend(AggregationPrimitive):
    """Calculate a linear least-squares regression for the values of the time
    series versus the sequence from 0 to length of the time series minus one.
    This feature assumes the signal to be uniformly sampled. It will not use
    the time stamps to fit the model.

    Args:
        attr (str) : Controls which of the characteristics are returned.
            Possible extracted attributes are:
                ['pvalue', 'rvalue', 'intercept', 'slope', 'stderr'].

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.linear_trend
    """
    name = "linear_trend"
    input_types = [Numeric]
    return_type = Numeric
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / skewness.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import skewness


class Skewness(AggregationPrimitive):
    """Returns the sample skewness of x (calculated with the adjusted
    Fisher-Pearson standardized moment coefficient G1).

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.skewness
    """
    name = "skewness"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def get_function(self):
        return skewness
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / spkt_welch_density.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import spkt_welch_density


class SpktWelchDensity(AggregationPrimitive):
    """This feature calculator estimates the cross power spectral density of
    the time series at different frequencies. To do so, the time series is
    first shifted from the time domain to the frequency domain.

    Args:
        coeff (int) : Value of coefficient.

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.spkt_welch_density
    """
    name = "spkt_welch_density"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def __init__(self, coeff):
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / first_location_of_maximum.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import \
    first_location_of_maximum

from ..utils import to_array


class FirstLocationOfMaximum(AggregationPrimitive):
    """Returns the first location of the maximum value of x. The position is
    calculated relatively to the length of x.

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.first_location_of_maximum
    """
    name = "first_location_of_maximum"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def get_function(self):
        def function(x):
            return first_location_of_maximum(to_array(x))

        return function
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / longest_strike_below_mean.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import \
    longest_strike_below_mean


class LongestStrikeBelowMean(AggregationPrimitive):
    """Returns the length of the longest consecutive subsequence in x that is
    smaller than the mean of x.

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.longest_strike_below_mean
    """
    name = "longest_strike_below_mean"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def get_function(self):
        return longest_strike_below_mean
github FeatureLabs / featuretools-tsfresh-primitives / featuretools_tsfresh_primitives / primitives / count_above.py View on Github external
from featuretools.primitives import AggregationPrimitive
from featuretools.variable_types import Numeric
from tsfresh.feature_extraction.feature_calculators import count_above


class CountAbove(AggregationPrimitive):
    """Returns the percentage of values in x that are higher than t

        Args:
            t (float) : value used as threshold

    Docstring source:
    https://tsfresh.readthedocs.io/en/latest/api/tsfresh.feature_extraction.html#tsfresh.feature_extraction.feature_calculators.count_above
    """
    name = "count_above"
    input_types = [Numeric]
    return_type = Numeric
    stack_on_self = False

    def __init__(self, t):
        self.t = t