我的代码使用所有megasena结果的csv文件。
data['Data'] = pd.to_datetime(data['Data'], format='%d/%m/%Y')
features = data[['Data', 'Conc']]
labels = data[['NR1', 'NR2', 'NR3', 'NR4', 'NR5', 'NR6']]
# convert date column to numerical features
features['Day'] = features['Data'].dt.day
features['Month'] = features['Data'].dt.month
features['Year'] = features['Data'].dt.year
# normalize the features (year should have more weightage than day and month)
features['Day'] = features['Day'] / 31.0
features['Month'] = features['Month'] / 12.0
features['Year'] = (features['Year'] - 2000) / 20.0
# split the data into training and testing sets
train_features = features[features['Conc'] <= 2601].values
train_labels = labels[labels.index <= 2601].values
test_features = features[features['Conc'] > 2601].values
# define the model architecture
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(64, input_shape=[5], activation='relu'),
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(6, activation='softmax')
])
这个错误发生在训练中,我已经尝试通过将日,月和年的类型改为float,np.float32,tf.float32来解决它,但没有一个解决了这个问题。
# train the model
model.fit(train_features, train_labels, epochs=100)
1条答案
按热度按时间avkwfej41#
找到的解决方案是将日期转换为浮点数并删除日期列