在使用AutoKeras中StructuredDataClassifier出现问题时,可能出现以下错误:
当数据集中某些列的数值类型不是浮点数时,会出现错误: "Object column detected as a feature column with nominal values. "。
内存不足,程序无法运行。
您可以按照以下步骤进行解决:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
data = pd.read_csv("data.csv")
# Identify non-float columns
categorical_columns = []
for col in data.columns:
if data[col].dtype != "float64":
categorical_columns.append(col)
# Use a Label Encoder for each non-float column
for col in categorical_columns:
le = LabelEncoder()
data[col] = le.fit_transform(data[col].astype(str))
import autokeras as ak
clf = ak.StructuredDataClassifier(max_trials=10)
clf.fit(X_train, y_train)
通过这两个步骤,您应该可以成功地使用AutoKeras中的StructuredDataClassifier。