通过to_categorical变量进行StratifiedKFold?

时间:2019-08-30 15:13:46

标签: optimization conv-neural-network

我想使用以下代码优化ConvNeuralNetwork:

seed = 7
np.random.seed(seed)
stratKFold = StratifiedKFold(n_splits=5, shuffle=True, random_state=seed)
model = KerasClassifier(build_fn=randomized_search_model, verbose=0)
randomized_Search = RandomizedSearchCV(estimator=model, 
                 param_distributions=params, cv=stratKFold, n_jobs=-1)

results = randomized_Search.fit(X,y)

使用此代码,我会收到错误消息

ValueError: Supported target types are: ('binary', 'multiclass'). Got 'multilabel-indicator' instead.

目标变量y是使用to_categorical的一键编码类矢量。由于StratifiedKFold基于y标签,因此我正在寻找解决此问题的合适方法。我想使用StratifiedKFold而不是KFold,因为数据集不平衡。 有人暗示吗? 有人提示吗?

0 个答案:

没有答案