No features can be generated from the specified primitives

27 Views Asked by At

Why is this error being generated?

How can resolve it?

import featuretools as ft
import pandas as pd

# Define the column headers
column_heads = ['UniqueIndex', 'AminoAcid', 'HECcode',
                'R13distance', 'R14distance', 'R15distance',
                'NeighborCount4Angstrom', 'NeighborCount45Angstrom',
                'NeighborCount5Angstrom', 'NeighborCount6Angstrom',
                'NeighborCount8Angstrom', 'HBondsCount']

# Read the CSV file, making sure to set delim_whitespace=True if your data is whitespace delimited
proteins_df = pd.read_csv(filepath_or_buffer=r'C:\git\_origina_data\_v2.full.regular.unique_id.txt',
                          delim_whitespace=True, names=column_heads, header=None)

# Set the 'UniqueIndex' column as the index of the DataFrame
proteins_df.set_index('UniqueIndex', inplace=True)

# Initialize the EntitySet
es = ft.EntitySet(id="proteins_entity")

# Add the DataFrame to the EntitySet, using the 'UniqueIndex' as the unique index
es = es.add_dataframe(
    dataframe_name="proteins_df",
    dataframe=proteins_df,
    index='UniqueIndex'  # Make sure this matches the name of the index column
)

# Specify which primitives to use if the default ones are not suitable
# You can get a list of all primitives with ft.primitives.list_primitives()

# Now you can run deep feature synthesis (dfs) to create new features
feature_matrix, feature_defs = ft.dfs(
    entityset=es,
    target_dataframe_name="proteins_df",
    verbose=True,
    max_depth=1  # Depth is set to 1 since there's only one dataframe
)

# Display the tail of the generated feature matrix to verify the new features
print(feature_matrix.tail())

# Save the feature matrix to a new CSV file
feature_matrix.to_csv("proteins_feature_matrix.csv", index=True)  # Save with the index which is 'UniqueIndex'

C:\Users\pc\AppData\Local\Programs\Python\Python311\python.exe C:/git/_v2/_v2/_v2_featuretools/main.py
C:\Users\pc\AppData\Local\Programs\Python\Python311\Lib\site-packages\featuretools\entityset\entityset.py:1914: UserWarning: index UniqueIndex not found in dataframe, creating new integer column
  warnings.warn(
Built 0 features
Traceback (most recent call last):
  File "C:\git\_v2\_v2\_v2_featuretools\main.py", line 32, in <module>
    feature_matrix, feature_defs = ft.dfs(
                                   ^^^^^^^
  File "C:\Users\pc\AppData\Local\Programs\Python\Python311\Lib\site-packages\featuretools\utils\entry_point.py", line 39, in function_wrapper
    raise e
  File "C:\Users\pc\AppData\Local\Programs\Python\Python311\Lib\site-packages\featuretools\utils\entry_point.py", line 32, in function_wrapper
    return_value = func(*args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\pc\AppData\Local\Programs\Python\Python311\Lib\site-packages\featuretools\synthesis\dfs.py", line 280, in dfs
    features != []
AssertionError: No features can be generated from the specified primitives. Please make sure the primitives you are using are compatible with the variable types in your data.

Process finished with exit code 1

0

There are 0 best solutions below