import tensorflow as tf
import pandas as pd
from sklearn.model_selection import train_test_split
X = data.iloc[:, data.columns != 'target']
y = data.iloc[:, data.columns == 'target']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=45, stratify=y)
age = tf.compat.v1.feature_column.numeric_column('age')
sex = tf.compat.v1.feature_column.numeric_column('sex')
cp = tf.compat.v1.feature_column.numeric_column('cp')
trestbps = tf.compat.v1.feature_column.numeric_column('trestbps')
chol = tf.compat.v1.feature_column.numeric_column('chol')
fbs = tf.compat.v1.feature_column.numeric_column('fbs')
restecg = tf.compat.v1.feature_column.numeric_column('restecg')
thalach = tf.compat.v1.feature_column.numeric_column('thalach')
exang = tf.compat.v1.feature_column.numeric_column('exang')
oldpeak = tf.compat.v1.feature_column.numeric_column('oldpeak')
slope = tf.compat.v1.feature_column.numeric_column('slope')
ca = tf.compat.v1.feature_column.numeric_column('ca')
thal = tf.compat.v1.feature_column.numeric_column('thal')
feat_cols = [age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca, thal]
# create input func
input_func = tf.compat.v1.estimator.inputs.pandas_input_fn(x=X_train, y=y_train, num_epochs=None,
shuffle=True)
# create model
model = tf.compat.v1.estimator.LinearClassifier(feature_columns=feat_cols)
# train model
model.train(input_fn=input_func, steps=5000)
ОШИБКА:
TypeError: List of Tensors when single Tensor expected
Есть несколько ответов, связанных с типом ошибки, но я не могу понять это в этом контексте.