featuretools.calculate_feature_matrix(features, entityset=None, cutoff_time=None, instance_ids=None, entities=None, relationships=None, cutoff_time_in_index=False, training_window=None, approximate=None, save_progress=None, verbose=False, chunk_size=None, n_jobs=1, dask_kwargs=None, progress_callback=None)[source]

Calculates a matrix for a given set of instance ids and calculation times.

  • features (list[FeatureBase]) – Feature definitions to be calculated.

  • entityset (EntitySet) – An already initialized entityset. Required if entities and relationships not provided

  • cutoff_time (pd.DataFrame or Datetime) – Specifies at which time to calculate the features for each instance. The resulting feature matrix will use data up to and including the cutoff_time. Can either be a DataFrame with ‘instance_id’ and ‘time’ columns, DataFrame with the name of the index variable in the target entity and a time column, or a single value to calculate for all instances. If the dataframe has more than two columns, any additional columns will be added to the resulting feature matrix.

  • instance_ids (list) – List of instances to calculate features on. Only used if cutoff_time is a single datetime.

  • entities (dict[str -> tuple(pd.DataFrame, str, str)]) – dictionary of entities. Entries take the format {entity id: (dataframe, id column, (time_column))}.

  • relationships (list[(str, str, str, str)]) – list of relationships between entities. List items are a tuple with the format (parent entity id, parent variable, child entity id, child variable).

  • cutoff_time_in_index (bool) – If True, return a DataFrame with a MultiIndex where the second index is the cutoff time (first is instance id). DataFrame will be sorted by (time, instance_id).

  • training_window (Timedelta or str, optional) – Window defining how much time before the cutoff time data can be used when calculating features. If None, all data before cutoff time is used. Defaults to None.

  • approximate (Timedelta or str) – Frequency to group instances with similar cutoff times by for features with costly calculations. For example, if bucket is 24 hours, all instances with cutoff times on the same day will use the same calculation for expensive features.

  • verbose (bool, optional) – Print progress info. The time granularity is per chunk.

  • chunk_size (int or float or None) – maximum number of rows of output feature matrix to calculate at time. If passed an integer greater than 0, will try to use that many rows per chunk. If passed a float value between 0 and 1 sets the chunk size to that percentage of all rows. if None, and n_jobs > 1 it will be set to 1/n_jobs

  • n_jobs (int, optional) – number of parallel processes to use when calculating feature matrix.

  • dask_kwargs (dict, optional) –

    Dictionary of keyword arguments to be passed when creating the dask client and scheduler. Even if n_jobs is not set, using dask_kwargs will enable multiprocessing. Main parameters:

    cluster (str or dask.distributed.LocalCluster):

    cluster or address of cluster to send tasks to. If unspecified, a cluster will be created.

    diagnostics port (int):

    port number to use for web dashboard. If left unspecified, web interface will not be enabled.

    Valid keyword arguments for LocalCluster will also be accepted.

  • save_progress (str, optional) – path to save intermediate computational results.

  • progress_callback (callable) –

    function to be called with incremental progress updates. Has the following parameters:

    update: percentage change (float between 0 and 100) in progress since last call progress_percent: percentage (float between 0 and 100) of total computation completed time_elapsed: total time in seconds that has elapsed since start of call