I run the following code:
seed = 7
np.random.seed(seed)
kfold = StratifiedKFold(n_splits=5, shuffle=True, random_state=seed)
for train, test in kfold.split(X, Y):
model = Sequential()
model.add(Dense(64, input_dim=12, activation='relu'))
model.add(Dense(1))
model.compile(optimizer='rmsprop', loss='mse', metrics=['mae'])
model.fit(X[train], Y[train], epochs=10, verbose=1)
And got the following error:
ValueError Traceback (most recent call
last) in ()
6 lst_accu_stratified = []
7
----> 8 for train_index, test_index in skf.split(X, Y):
9 x_train_fold, x_test_fold = X_scaled[train_index], X_scaled[test_index]
10 y_train_fold, y_test_fold = Y[train_index], Y[test_index]
3 frames
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_split.py
in _make_test_folds(self, X, y)
644 raise ValueError(
645 'Supported target types are: {}. Got {!r} instead.'.format(
--> 646 allowed_target_types, type_of_target_y))
647
648 y = column_or_1d(y)
ValueError: Supported target types are: ('binary', 'multiclass'). Got
'continuous' instead.
It doesn't make sense for this model not accepting continuous data. What's wrong?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…